Debugging
When working on your WordPress site, it’s essential to have tools that make debugging easier. WP_DEBUG is a helpful feature built into WordPress that does just that.
This feature is available on sites with the WordPress.com Business or Commerce plan.
Enable WP_DEBUG
To activate debugging mode, take the following steps:
- Connect to your WordPress site using your preferred SFTP client.
- Once connected, locate the
wp-config.php
file in the root directory of your WordPress installation. - Open the wp-config.php file in your text editor.
- Update the WP_DEBUG line: Replace the line
define( 'WP_DEBUG', false );
with:
define( 'WP_DEBUG', true );
if ( WP_DEBUG ) {
@error_reporting( E_ALL );
@ini_set( 'log_errors', true );
@ini_set( 'log_errors_max_len', '0' );
define( 'WP_DEBUG_LOG', true );
define( 'CONCATENATE_SCRIPTS', false );
define( 'SAVEQUERIES', true );
}
5. Save the changes you made to the wp-config.php
file.
Retrieve Logs
Now you’ve enabled WP_DEBUG, you can retrieve logs to help diagnose issues:
- Reconnect to your WordPress site using SFTP.
- Navigate to the wp-content directory and locate the debug.log file.
- Download or view the
debug.log
file. You can download thedebug.log
file to your computer or view it directly using a text editor.
Disable WP_DEBUG
To prevent performance issues and keep sensitive information secure, it’s important to disable WP_DEBUG in your production environment after you’ve finished debugging.
Once you’ve finished debugging, disable WP_DEBUG with the following steps:
- Reconnect to your WordPress site again with SFTP.
- Locate the
wp-config.php
file in the root directory of your WordPress installation. - Open the
wp-config.php
file in your text editor. - Update WP_DEBUG by replacing
define( 'WP_DEBUG', true );
withdefine( 'WP_DEBUG', false );
. - Save the
wp-config.php
file and upload it to your site.
Last updated: September 05, 2024