How to: The PHP Error Logs

Something wrong happened while you were using a plugin in WordPress (freeze, or something similar) or your website is crashing with a blank screen… or anything else? Checking your PHP Error Logs is the first reaction you should have. 

The PHP Error Logs is not the Access Error Logs (which is the error related to your web server and not PHP).

What is the PHP Error Logs?

PHP Error Logs contain errors related to programming errors but also memory, space, and timeout issues. They are really important to troubleshoot issues.

Please note that the PHP Error Logs is rarely empty (as warnings are also logged in them). 

Where to find the PHP Error Logs?

Usually, you can access them through the administration system shared by your hosting service (not the WordPress one; it can be Plesk, cPanel, or their own system).

Depending on how your hosting service set up your environment, they can also be accessed thanks to plugins (try Error Log Monitor) or even the Meow Apps Dashboard (at the bottom right on it you will find a link to your logs).

Unfortunately, PHP Error Logs are not always made accessible by the hosting services, especially the cheap ones. If you find an empty file (or no file at all), the logs might be disabled.

If you can’t find them, or if they are empty and you have issues, contact your hosting service and ask them for access to your PHP Error Logs (and if they are good, for troubleshoot about your issue at the same time).

WordPress and the PHP Error Logs

There are some ways to get the errors to be written to a specific files through WordPress. This also highly depends on how your hosting service is set up, and if they allow it to be done. Please give it a try! You can simply add this in your wp-config.php file, right before the /* That’s all, stop editing! Happy blogging. */ line.

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

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

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

Note: this code the one recommended officially by WordPress for debugging purposes.

Additional Information

There is an additional thread on StackOverflow where people are discussing this, have a look here: Where does PHP store the error log?