How to Use WP_DEBUG?

Introduction

PHP is a well known programming language used by Wordpress having its own debugging mechanism. WordPress has some pre-defined debugging mechanisms like WP_DEBUG. The WP_DEBUG is a constant located in wp-config.php file of any wordpress based website.

 

When can we use the WP_DEBUG?

WP_DEBUG is very helpful to debug and identify unknown issues that starts appearing on your WordPress Websites. When WP_DEBUG is enabled, it will start throwing PHP notices, debug messages and deprecated function alerts in your WordPress website. By examining those errors & notices, you can easily identify and update required components of the WordPress or PHP. It is the most helpful function to identify the deprecated function in WordPress themes or WordPress plugins and to avoid the known issues of website hacking.

How can we use the WP_DEBUG?

 To turn on or enable the WP_DEBUG, you have to add the single line of code in wp-config.php file, which is as follows:

define('WP_DEBUG', True );

Enabling WP_DEBUG will fire some additional commands which will increase website load time. So,  it is advisable to keep it disabled unless you need it. By default, WP_DEBUG is disabled, "True" will use to enabled and "False" will use to disabled. 

How it works?

After enabling the WP_DEBUG, WordPress will start generating errors & logs and they will be recorded in debug.log file. The location of debug.log file is "wp-content" folder. You can explore this file to see the list of errors, logs & alerts of your WordPress blog.

It is also necessary to turn on the WP_DEBUG_LOG & turn off 'WP_DEBUG_DISPLAY' feature which will start saving all errors to a debug.log file.

define ( 'WP_DEBUG_LOG', true);
define ( 'WP_DEBUG_DISPLAY', false);

Disabling of WP_DEBUG_DISPLAY will start saving all these logs to your log file.

 

Precautions


If you're trying to debug something on your live site, use WP_DEBUG with "DISPLAY" feature "OFF". If this is not done, all the errors and notices will start appearing on the front-end and visible to your site visitors.

If the boolean values are not set in command  ('), it will be considered as 'true'. 

  • 54 Users Found This Useful

Was this answer helpful?

Related Articles

How to fix WordPress 403 forbidden error in WordPress?

What is 403 FORBIDDEN ERROR IN WORDPRESS?  The 403 Forbidden error code is shown to a web...

How to move/transfer WordPress website through FTP?

Regardless of the reason, most of people are gone through the stressful experience of moving a...

How to install WordPress

How to install WordPress This tutorial will show you how to install WordPress. For this...

How to secure complete backup of your WordPress website?

We do maintain the backup of our shared hosting clients' accounts regularly, however it is highly...

How to Fix the 500-Internal Server Error in WordPress?

So you have been receiving 500 Internal Server Error in your WordPress website? Don’t panic, have...