Freigeben über


Enable WordPress Error Logs

Logs can help identify slowness, HTTP 500 Fatal Errors,  WordPress "white screen of death" and other issues your Azure App Service Web App may be experiencing.

To enable error logging in WordPress, you will have to make both of the following changes.


 Quick Instructions

 

.user.ini

Within wwwroot directory, create a file named .user.ini
Add the following setting within your file:

log_errors=on

wp-config.php

Within wwwroot directory, open wp-config.php
Add the following settings BEFORE the line /* That's all, stop editing! ... . */ :

//Enable WP_DEBUG mode define('WP_DEBUG', true);

//Enable Debug Logging to /wp-content/debug.log define('WP_DEBUG_LOG', true);

//Supress errors and warnings to screen define('WP_DEBUG_DISPLAY', false);

//Supress PHP errors to screen ini_set('display_errors', 0);


 

Step-by-Step instructions

The .user.ini and wp-config.php files can be updated using either Kudu console or FTP Client (such as FileZilla).

Instructions for Kudu are below:

Step 1. Browse to Kudu

In your favorite Microsoft browser, surf to https://<sitename>.scm.azurewebsites.net.

Ex: if your Azure App Service Web App name is "example", then surf to https://example.scm.azurewebsite.net

Once there, you will see the interface below:

step1

Click 'Debug Console' and select 'CMD'

step2

Step 2. Traverse to wwwroot folder

step3

step4

Step 3. Create .user.ini file

If .user.ini already exists, skip to step 4, otherwise create the .user.ini file

step4a

touch .user.ini

Step 4. Update the .user.ini file

step5

step6

log_errors=on

 Step 5. For WordPress, update wp-config.php

step7

step8

step9

Save the file:

 step6a9a

 


Q & A

1. There are errors in my application, where do I find the error logs?

First, ensure that logging is enabled for PHP in .user.ini as mentioned above in (1). Second, if you are searching for WordPress logs, verify step (2) is complete.

By default, PHP Errors are located at d:\home\LogFiles\php_errors.log and
WordPress Debug Log is located at d:\home\site\wwwroot\wp-content\debug.log

2. I have local cache enabled - what happened to my logs?

If you have local cache enabled, check the d:\home\LogFiles\xxxxx_timestamp folders.

3. I want to capture all logs in one file, not two - what should I do?

WordPress stores errors logs within the wp-content folder.

To integrate these messages into d:\home\LogFiles\php_errors.log, edit d:\home\site\wwwroot\wp-includes\load.php and comment the following line:

ini_set ('error_log', WP_CONTENT_DIR . '/debug.Log' );

The updated code should look like this:

load_php

Once this change has been made, all subsequent WordPress logs will be saved at the default error_log location.

4. How do I verify my error log location?

Create a .php file (example: myinfo.php) within the wwwroot directory and place the following code:

<?php phpinfo();

After you've saved the file, browse to

https://<app name>.azurewebsites.net/myinfo.php

To find the location, search the page for "error_log".

Once the path has been located, remember to delete the myinfo.php file so others won't have access to your environment configuration.

5. I want my local timezone in the logs - how do I update this?

Click here for a list of Time Zones.

Within .user.ini file, add the time zone relevant to your app:

date.timezone = "US/Central"

For WordPress logs, update the Time Zone through the WordPress admin interface. Click "settings" and then "general". Select the proper Time Zone within the drop down:

wordpress_timezone

Save your changes.