Yogesh Chauhan's Blog

Debugging in WordPress Part 2: WP_DEBUG_LOG and WP_DEBUG_DISPLAY

in WordPress on January 24, 2021

This article was published on WordPress.org

WP_DEBUG_LOG is a companion to WP_DEBUG that causes all errors to also be saved to a debug.log log file

This is useful if you want to review all notices later or need to view notices generated off-screen (e.g. during an AJAX request or wp-cron run).

Note that this allows you to write to log file using PHP’s built in error_log() function, which can be useful for instance when debugging Ajax events.

When set to true, the log is saved to debug.log in the content directory (usually wp-content/debug.log) within your site’s filesystem.

Alternatively, you can set it to a valid file path to have the file saved elsewhere.

define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' );

for WP_DEBUG_LOG to do anything, WP_DEBUG must be enabled (true).

You can turn off WP_DEBUG_DISPLAY independently.


WP_DEBUG_DISPLAY is another companion to WP_DEBUG that controls whether debug messages are shown inside the HTML of pages or not.

The default is ‘true’ which shows errors and warnings as they are generated. Setting this to false will hide all errors.

This should be used in conjunction with WP_DEBUG_LOG so that errors can be reviewed later.

define( 'WP_DEBUG_DISPLAY', false );

For WP_DEBUG_DISPLAY to do anything, WP_DEBUG must be enabled (true).

You can control WP_DEBUG_LOG independently.

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #5 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
How to scroll contents of HTML body horizontally and vertically using JavaScript?JavaScriptHow to get Current Year, Month and Date in JavaScript?JavaScriptHow to convert datetime to date format in JavaScript?JavaScriptHow to avoid element shift on border change while hovering in CSS?CSSHow to create Flickering Texts using CSS?CSSWhat is IPS(Intrusion Prevention System), How Does It Work and What are the Detection Types?Miscellaneous