Overview
This article walks you through how to enable debug mode in WordPress to write errors to a log file without disturbing your live website.
Background
WordPress provides a debugging tool that helps you find the cause of any errors on your website. This tool can display information in two ways:
- Live on your website — This is not recommended if your website is live to the public, but can be a quick way to troubleshoot an issue.
- Create a debug log file — This creates a log file on the server to help you troubleshoot an issue.
Enabling debug mode
To enable debug mode:
- Log in to your server via SSH or FTP.
- Edit the wp-config.php file using SSH or your FTP client.
- The following line appears near the bottom:
-
define('WP_DEBUG', false);
- Replace that line with these three lines:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_DISPLAY', false ); define( 'WP_DEBUG_LOG', true );
It's not recommended to change WP_DEBUG_DISPLAY to true as this displays any errors on your live website.
By enabling WP_DEBUG_LOG, you can view the same errors in your /wp-content/debug.log file instead.
When an error occurs in WordPress, it now writes to a file titled debug.log, located in your /wp-content/ directory. Open this file using SSH or your FTP client to view the debug report.
Using a plugin to view the debug log
You can also use a plugin to help you debug your site and view your debug log. See this article for information on how to manage and install a plugin. When searching for a plugin, try typing in debug as a search term, as there are many different options for you to choose from.