How to identify/review PHP errors on Azure Web Apps using Log Stream service
If you are getting internal server errors (HTTP error 500) trying to request your PHP application inside Azure Web Apps,
You can do the following:
-
Create .user.ini file and set log_errors = on to check if there a php error related, following this reference from step 1 to 4: Login PHP errors
-
But sometimes there are not php errors related, could be related to configuration, auth permissions, cache, file issues, etc. In this situation you can use Log stream feature inside your web app. To use this feature you need to activate Diagnostics Logs on azure portal for your web app. You can follow this reference for more information: Enable Diagnostics Logs in Azure Web Apps
Then go to Log stream and Start this service. Just remember that this service will be logging all requests to the current web app.
Try to request again the web app that is throwing the HTTP 500 error and you will get a better detail of what is failing in your site.
In this example. My web app is having some access issues with web.config, probably the web app doesn’t have any web.config or the correct permissions to access this file.
You can clear the log stream service and check the error. In this case my web app didn’t have any correct configuration in web.config file.
I fixed the problem and I was able to request successfully the php application.
You can request again web app after you fix the problem and you will start getting 200 successful requests.
You can run this service from Kudu Console or your command prompt using cURL using the following command:
curl -u {username} https://{YOURWEBAPPNAME}.scm.azurewebsites.net/logstream
Or using Powershell or CLI following these references:
For example if you are using CLI:
azure site log tail {yourwebapp}
If you get another internal server error:
You can activate the error filter in CLI using this command:
azure site log tail {yourwebapp} --filter Error
In this case my web.config was not well-formed XML and I was able to detect and fix the issue.
Usually PHP fatal errors could map to internal server error,s but not all HTTP 500 error map to PHP error, take a look on php error log for more details on this.
I hope this can help you to identify php errors. This service is useful for all applications inside Azure Web App.