Print

Enable WordPress Debug Log

You may get an error 500 or a blank page when you open your WordPress website. To find out which plugin or broken code is causing that error, you need to tell WordPress to write the errors into a log file or to show them on the screen instead of showing just the white blank page.

You can enable the WordPress debug mode by editing a few lines in the wp-config.php file of your WordPress installation.

To enable debugging mode in WordPress, follow the steps:

  1. Login to cPanel or log in to your site via FTP
  2. Use the cPanel File Manager or your FTP client to edit the file wp-config.php
  3. Add the lines below to the wp-config.php or if they already exist just change their values:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Attention: Make sure that you write the lines exactly as shown.
Do not forget any semicolon or other characters!

After reloading the website, WordPress writes all PHP errors into the file debug.log. The file is written into in the folder: wp-content/debug.log

If you want to see the debug log errors directly on the screen instead of needing to look into the debug.log change WP_DEBUG_DISPLAY to
define( 'WP_DEBUG_DISPLAY', true );

When we ask you to do so, please send us the debug.log file.
This file helps us to resolve issues you have with WP Staging.

WordPress Debug.log wp-config.php
How to activate the WordPress debug mode and write errors into debug.log

WordPress Does not Create the Debug Log

Some hosting providers[1] do not create the WordPress debug.log at all. They catch all errors and warnings which are created by WordPress and write them into a separate log file. If WordPress does not create the debug.log, check if there is another file in the root of your website like error_log or a folder like /logs.

If you do not see any error logs at all, please ask your hosting provider where they store the log files.

Alternatively, you can try to set in the wp-config.php
define( 'WP_DEBUG_DISPLAY', true);

If this works, you will see the relevant errors on the front end. That will help you to resolve the fatal error which you get, but this should be used only in the last instance. Your visitors should not see such PHP error messages for security purposes. If you do not need it any longer, make sure to switch the value back to false.

You find more detailed instructions about how to enable the WordPress debug mode at https://codex.wordpress.org/Debugging_in_WordPress

At the time of writing this article: [1]  HostGator

Change the location of the debug.log

You can change the position of written errors by changing the value of the constant WP_DEBUG_LOG from true to a path of your choice like so:

define('WP_DEBUG_LOG', ABSPATH . '/logs/errors.log');

That allows you to write errors into another file located elsewhere and even enable you to write errors to  dev/stderr or /dev/stdout.
That can be helpful if you use docker or another development environment and want to have all your logs into one location.