YogeshChauhan.com
Debugging in WordPress Part 2: WP_DEBUG_LOG and WP_DEBUG_DISPLAY
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 );
-or-
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

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.

dreamhost

Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 2 How to zoom an element on hover using CSS? Mar 2 the box-sizing property in CSS Mar 2 WordPress: How to access first and random row values from a repeater field in ACF? Mar 1 The basics of CSS Box model Feb 27 WordPress: How to display slider repeater fields in ACF? Feb 26 Simple Page Hit Counter in PHP

You might also like these

Recursive WITH Queries in Postgres (Common Table Expressions)PostgresHow to add a scroll back to top button using JavaScript and CSS?CSSAlways add associated labels to your Form elementsUI/UXGive buttons accessible namesUI/UXSelect statement in Postgres with examplesPostgresA Step by Step Guide to Make RSS in XML For Any Website or Blog For FreeMisc