This article explains how to activate the WordPress debug mode and create the WordPress debug.log file.
Are you experiencing a fatal error or a blank white page on your WordPress live site?
Try out WP STAGING to prevent such fatal errors on your production site!
Read this developer short novel to learn why working on a staging site is so important.
When you open your WordPress website, do you get an error 500 or a blank page?
To determine which plugin or code is causing this error, you can tell WordPress to write all errors to a log file called debug.log.
Alternatively, you can display the errors on the screen instead of seeing a blank white page.
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:
- Login to cPanel or log in to your site via FTP
- Use the cPanel File Manager or your FTP client and edit the file
- Copy the lines below to the file
wp-config.phpor if they already exist, change their values to true:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false );
Attention: Make sure you copy the lines exactly as shown, and don’t forget a semicolon or other characters!
- Paste the copied lines directly above the line that says
/* That's all, stop editing! Happy publishing. */
After reloading the website, WordPress will write all PHP errors into the file
WordPress saves that file into the folder:
Display Errors on the WordPress Frontend
You and your visitors can see any PHP warning and error message on the front page.
For security reasons, disable the WP_DEBUG_DISPLAY constant after fixing the site errors.
If you want to see the debug log errors directly on the screen instead of activating the debug.log file, change the line that says
define( 'WP_DEBUG_DISPLAY', false );
Rename it to:
define( 'WP_DEBUG_DISPLAY', true );.
WordPress Does not Create the debug.log Log File.
Some hosting providers do not allow the creation of the WordPress debug.log. They catch all PHP errors and let WordPress writes them into a separate log file.
If WordPress can not create the debug.log, check if you see another file in the root directory, such as
error_log or a folder
/logs or similar.
If you do not see any error logs, please ask your hosting provider where they store the log files.
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 enabling the WordPress “debug” mode at https://wordpress.org/support/article/debugging-in-wordpress/.
At the time of writing this article:  HostGator
Change the Location of the debug.log
You can change the position of written errors by changing the value of the constant
Open wp-config.php and search the line that contains WP_DEBUG_LOG.
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_LOG','/logs/errors.log' );
That makes WordPress write the error messages into another log file.
As a destination path, you can also write
/dev/stdout. That can help if you use Docker or another development environment and want all the logs in a shared 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.