This is just a short post about how to get error information for PHP sites running in Windows Azure Web Sites. We all want to know when something goes wrong, and better yet, we want to know why something goes wrong. Hopefully, the information here will help get you started in understanding the *why*. Note that many of the options below are probably intended for use when you are developing a site. You may want to turn off some of the functionality below when you are ready to go to production.
Turn on logging options
In the Windows Azure Management Portal, on the CONFIGURE tab for your website, you have the option of turning on three logging options: web server logging, detailed error messages, and failed request tracing. To turn these on, find the diagnostics section and click ON next to each (be sure to click SAVE at the bottom of the page!):
One way to retrieve these logs is via FTP. Again in the Azure Management Portal, down the right hand panel you should see FTP HOSTNAME and DEPLOYMENT /FTP USER. Using your favorite FTP client, you should be able to use those values (along with your password) to get the logs:
Another way to retrieve these files is by using the Windows Azure Command Line Tools for Mac and Linux. The following command will download a .zip file to the directory from which it was executed:
azure site log download <site name>
Note: You may have to run that as a super user on Mac or Linux (i.e. sudo azure …)
Configure PHP error reporting
Whether you are using the built-in PHP runtime or supplying your own, you can configure PHP to report errors via the php.ini file. If you are using a custom PHP runtime, you can simply modify the accompanying php.ini file, but if you are using the built-in PHP runtime, you need to use a .user.ini file. In either case, here are some of the settings I’d change:
error_log = “D:\home\site\wwwroot\bin\errors.log”
Notice that for the error_log setting, you need to create a bin directory in your application root if you want to use the path I’m using. Regardless, you can only write to files in your application root, so you need to know that it is at D:\home\site\wwwroot.
I wrote a post a couple of week ago that describes how to enable XDebug for both the built-in PHP runtime and for a custom PHP runtime, so I just point you there: How to Enable XDebug in Windows Azure Web Sites. If you follow those instructions, you can get XDebug profiles via FTP:
When I started looking some of the errors for my site, I noticed that there were lots of 404 errors for favicon.ico. One way to avoid these errors is to simply add a favicon.ico file to your root directory. Other ways are outlined in this Stackoverflow post: How to prevent favicon.ico requests.