How to enable WP_DEBUG in WordPress

WP_DEBUG option controls the reporting of some errors and warnings and enables use of the WP_DEBUG_DISPLAY and WP_DEBUG_LOG settings.

In this quick tutorial I will show you how to enable the WP_DEBUG feature and output the results to a log file.

Step 1. Open wp-config.php file in your favorite text editor

Step 2. Add the following line right after the beginning php tag:

define( 'WP_DEBUG', true );

Step 3. Go to your website and check for errors

Log WordPress errors to a file using the WP_DEBUG_LOG option

Another handy option is the WP_DEBUG_LOG, which in combination to the WP_DEBUG option will save all error messages into a debug.log file located inside the /wp-content/ directory.

To enable debug.log file, add the following code to the wp-config.php file:

define('WP_DEBUG_LOG', true);

Afterwards open the /wp-content/debug.log file and view the errors.

NOTE: Database errors are printed only if WP_DEBUG is set to true. Database errors are handled by the wpdb class and are not affected by PHP’s error settings.

Was this post helpful?

Leave a Reply