Here we will cover how to enable and configure various debugging options in WordPress. Some of these settings include writing errors to an error log, saving database queries for debugging purposes, and enabling dev versions of core CSS and JavaScript files instead of the minified versions.
These changes are made in the wp-config.php file.
Related Articles
WordPress Error: Memory Exhausted
WordPress Error: 'break' not in the 'loop' or 'switch' context
WordPress HTTP Error when Uploading Images
WordPress Redirect Loop Error
White Screen/500 HTTP Error on WordPress Website
Enabling and Configuring WordPress Debugging
TIP: For more detailed information on debugging, view the forum on WordPress.org.
NOTE: Enabling wp-debug will log all errors, notices, and warnings to a file called debug.log in the wp-content directory. It will also show errors on the site when enabled. When set to false, the errors will not be shown on the site and they will not be logged.
- Log into cPanel
- Locate the Document Root of the Domain
- Open File Manager
- Navigate to the Document Root of the Domain in File Manager
- Locate the wp-config.php file
- Right-click on the file and select Edit
- Right-click on the file and select Edit
- Add a line containing any of the desired directive(s) listed below
NOTE: Any directives added should be on a new line and inserted BEFORE
/* That's all, stop editing! Happy blogging. */
in the wp-config.php file.- To enable general debugging, insert the following line:
define( 'WP_DEBUG', true);
NOTE: Enabling debugging will render errors to the site publicly if no other configurations are set.
TIP: If the above line already exists in the wp-config.php file, simply edit the line that is already there from false to true. - To enable logging errors to a file, insert the following line:
define('WP_DEBUG_LOG', true);
- By default, errors are logged to wp-content/debug.log
- To set a custom file path for the log, you can add the file path to the same line in the following format:
define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' );
- To keep WP_DEBUG enabled, but disable errors from being displayed on the site, insert the following line:
define('WP_DEBUG_DISPLAY', false);
- To force WordPress to use dev versions of core CSS and JavaScript files instead of the minified versions, insert the following line:
define( 'SCRIPT_DEBUG', true );
- To save database queries for debugging purposes, insert the following line:
define( 'SAVEQUERIES', true );
- To enable general debugging, insert the following line:
- Save the file by clicking Save Changes on the top-right of the screen
EXAMPLE:
/* Add any custom values between this line and the "stop editing" 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 );
// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( 'SCRIPT_DEBUG', true );
/* That's all, stop editing! Happy publishing. */
IMPORTANT: Remember to change the WP_DEBUG back to false when you're done troubleshooting the issue.