How to Enable WordPress Debug Logging
How to Enable WordPress Debug Logging

Debugging is a skill set any developer or webmaster will need to learn. WordPress debug mode will help you identify and debug common WordPress issues and PHP errors such as deprecated functions and arguments. It’s not uncommon to see errors caused by a theme or plugin(s) and for an end-user to experience the white screen of death, 500 errors, or page not found in their browser.

Introduction

What is WordPress debugging? WP_DEBUG is a PHP constant to enable and disable WordPress debug mode. Enabling WordPress debug allows WordPress to log errors and display errors that are generated on a WordPress site. By default, WP_DEBUG is set to false and can be found in the wp-config.php file. Companions to WP_DEBUG are WP_DEBUG_LOG and WP_DEBUG_DISPLAY, which we’ll get into down below.

As a developer writing new code or developing a theme or plugin for release it’s a great habit to enable WordPress debug. In the end, it will help you write more bug-resistant code.

Please note, the true and false values aren’t surrounded by apostrophes (‘) because they are boolean (true/false) values.

WP_DEBUG Code Example

To enable WordPress debug you will need to locate your wp-config.php file and update WP_DEBUG from false to true.

// Enable WordPress Debug Mode
define( 'WP_DEBUG', true );

WP_DEBUG Code Placement

The wp-config.php will already have WP_DEBUG set to false. You’ll see this down around line 80 (at the time of this writing) as shown in the picture below.

Enable WordPress Debug Mode

Updating WP_DEBUG to true will enable various PHP errors, notices and warnings to be displayed that may be causing issues within your WordPress site.

WP_DEBUG_LOG Code Example

The WP_DEBUG_LOG will cause all errors to be saved to a debug.log file that you can download and view. To enable the debug.log file you will need to add the code below to the wp-config.php.

// Enable Debugging to /wp-content/debug.log File
define( 'WP_DEBUG_LOG', true );

For WP_DEBUG_LOG to save errors to the debug.log file WP_DEBUG must also be enabled.

WP_DEBUG_LOG Code Placement

The code for WP_DEBUG_LOG can be placed just below WP_DEBUG in the wp-config.php file as shown in the picture below.

Enable WordPress Debug Log

The debug.log file will be saved in your filesystem to wp-content/debug.log.

WordPress debug.log

WP_DEBUG_DISPLAY Code Example

The WP_DEBUG_DISPLAY will control whether or not error messages are displayed inside pages or not. To display errors on pages you will need to add the code below to the wp-config.php.

// Enable Display Errors and Warnings
define( 'WP_DEBUG_DISPLAY', true );

For WP_DEBUG_DISPLAY to display errors then WP_DEBUG must also be enabled.

WP_DEBUG_DISPLAY Code Placement

The code for WP_DEBUG_DISPLAY can be placed just below WP_DEBUG_LOG in the wp-config.php file as shown in the picture below.

Display WordPress Errors

Now you’ll see errors and warnings as they’re generated on the pages.

Sign Up for Our Newsletters

Get notified of the best deals on our WordPress themes.

You May Also Like

How to Limit WordPress Post & Page Revisions

Introduction By default, WordPress stores unlimited post revisions and page revisions in…

How to Add www in Your WordPress URL

Introduction Most web hosting providers will auto-install WordPress for you when you…

[FIX] WordPress User “Account Pending Not Currently Active”

Does your WordPress site allow new user registrations? If you’re seeing new…

How to Install WordPress Manually

Introduction Installing WordPress is a task that anyone without a technical web…