Enable WordPress Debug Log



This article explains how to activate the WordPress debug mode and let WordPress generate the debug.log file. You’ve likely found this article because you are experiencing a fatal error or a blank white page on your WordPress site. You can use WP STAGING to prevent such fatal errors on your production site!

You may get an error 500 or a blank page when you open your WordPress website. To determine which plugin or broken code is causing that error, you can tell WordPress to write the errors into a log file or show them on the screen instead of showing just the white blank page. For doing that, WordPress offers the ability to activate the “debug mode” and to write all errors into a file  with the name “debug.log.”

How to activate WordPress Debug Mode

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 and edit the file wp-config.php
  3. Copy the lines below to the file wp-config.php or if they already exist, change their values:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Attention: Make sure that you copy the lines exactly as shown, don´t forget any semicolon or other characters!

    1. Paste the copied lines directly above the line /* That's all, stop editing! Happy publishing. */
This picture shows where to paste the copied lines based on the screenshot.
Please paste the copied lines, as shown in the screenshot.

After reloading the website, WordPress writes all PHP errors into the file debug.log. WordPress saves that file into the folder: wp-content/debug.log

Take care when you use the step below: You can see the PHP error messages in the front end and your visitors. For security reasons, disable the WP_DEBUG_DISPLAY constant when you have fixed your site errors.

If you want to see the debug log errors directly on the screen instead of needing to look into the debug.log file, change the line
define( 'WP_DEBUG_DISPLAY', false ); 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 Does not Create the Debug Log File

Some hosting providers[1] do not create the WordPress debug.log at all. They catch all errors and warnings created by WordPress and write them into a separate log file.

If WordPress does not generate the debug.log, check if there is another file in the root directory of your website, such as error_log or a folder named /logs or similar.

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

Please note when using the step below: You can see the PHP error messages in the front end and your visitors. For security reasons, if you no longer need the view, make sure that you set the value back to “false.”

Alternatively, you can use the method mentioned above and change
define( 'WP_DEBUG_DISPLAY', false ); to
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.

You can find more detailed instructions about how to enable the WordPress “debug” mode at

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:

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

That allows you to write the error messages into another file located elsewhere.

As a destination path, you can also write dev/stderr or /dev/stdout. That can help if you use Docker or another development environment and want to have all your logs in a common location.

Disable Debug Mode in WordPress After Troubleshooting

We already mentioned this before, but If you are investigating WordPress website issues with the debugging mode, don’t leave it activated all the time. After using the debug.log, delete the file, and disable further error logging by changing the following lines from define( 'WP_DEBUG', true ); to define( 'WP_DEBUG', false );.

Otherwise, unauthorized persons could access that file and would be able to get sensitive information from your server.

Always disable the WordPress debugging mode when you’re finished with investigating and troubleshooting your website issues.
Updated on November 2, 2020