---
title: "WordPress Debugging Tools: WP_DEBUG, WP_DEBUG_LOG, WP_DEBUG_DISPLAY"
date: 2022-01-12
author: "Shiv"
featured_image: "https://malcure.com/wp-content/uploads/2022/01/debugging-wordpress.jpg"
categories:
  - name: "Code, CLI & Utilities"
    url: "/blog/utilities.md"
---

# WordPress Debugging Tools: WP_DEBUG, WP_DEBUG_LOG, WP_DEBUG_DISPLAY

![Debugging WordPress](https://malcure.com/wp-content/uploads/2022/01/debugging-wordpress-1024x682.jpg "WordPress Debugging Tools")Be it theme / plugin development or inspecting WordPress site for[ malware cleanup](https://malcure.com/blog/security/video-live-wordpress-malware-infection-removal-analysis/), WordPress debugging tools come in handy for identifying the potential issues. WordPress in **debug mode** helps in detecting errors, notices, and warnings which can be an underlying source of an issue or can be used for learning more details about any possible errors on your site.

Here are various PHP constants (permanent global variables) defined in WordPress for activating debug mode:

## WP\_DEBUG

**WP\_DEBUG** PHP constant is used to turn the debug mode on. When the debug mode is on it will display all PHP errors, notices and warnings including notices about deprecated functions and arguments within WordPress that are being used on your site. It is assumed to be false by default and is usually set to true in the [wp-config.php file](https://wordpress.org/support/article/editing-wp-config-php/) for development or debugging purposes.

Also See: [ How to Suppress Deprecation Notices in WordPress Using an MU Plugin](https://malcure.com/blog/utilities/suppress-deprecation-notices-in-wordpress/).



```
// This enables debugging.
define( 'WP_DEBUG', true );
```

```
// This disables debugging.
define( 'WP_DEBUG', false );
```

*Once done with inspecting / debugging, don’t forget to turn the debug mode off!*

## WP\_DEBUG\_LOG

By default when the debug mode is enabled, it displays all the errors, notices and warnings on the front-end. With **WP\_DEBUG\_LOG** enabled we can causes all errors to also be saved to a log file. This comes in handy for reviewing all notices later or to view notices generated off-screen (e.g. during an AJAX request or wp-cron run).

```
// Enable Debug logging
define( 'WP_DEBUG_LOG', true );
```

When WP\_DEBUG\_LOG is set to true, the log is saved to debug.log in the content directory at the following location: **wp-content/debug.log**. Alternatively, you can also specify a valid file path if you want to save the file elsewhere.

```
// Enable Debug logging and specifying the location for the log file
define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' );
```

## WP\_DEBUG\_DISPLAY

**WP\_DEBUG\_DISPLAY** is used to control whether debug messages are shown on site’s front-end or not. The default value is true which shows errors and warnings on the front-end as they are generated.

You can set WP\_DEBUG\_DISPLAY false to hide all the errors. This should be used in conjunction with WP\_DEBUG\_LOG so that errors can be reviewed later.

```
// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
```

### Enabling Debug Logs

Here is the complete code to enable debug logs. Edit your site’s wp-config.php file and replace **define( ‘WP\_DEBUG’, false );** with the following:

```
// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging, the file is save to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
```

Once errors are generated, a debug.log file site will be generated in wp-content folder. This file can be accessed via FTP / sFTP.

### Other debugging constants

**SCRIPT\_DEBUG:** This constant forces WordPress to use the “dev” versions of core CSS and JavaScript files rather than the minified versions that are normally loaded. This is useful when you are testing modifications to any built-in .js or .css files. The default value is false.

```
// Enable script debugging
define( 'SCRIPT_DEBUG', true );
```

**SAVEQUERIES:** This constant saves the database queries to an array (in the global $wpdb-&gt;queries) and that array can be displayed to help analyze those queries. When the value of the constant is set to true it causes each query to be saved and display how long that query took to execute, and what function called it.

```
// Enable Save Queries
define( 'SAVEQUERIES', true );
```

*This will have a performance impact on the site, so make sure to turn this off when you are not debugging.*

**Additional Resources:**

- [Official documentation for debugging in WordPress](https://wordpress.org/support/article/debugging-in-wordpress/)
- [WordPress debugging plugins](https://wordpress.org/plugins/search/debug/)
- [WP-CLI Cheat Sheet](https://malcure.com/blog/utilities/wp-cli-cheatsheet/)

If debugging reveals signs of infection, [scan your website for malware](https://malcure.com/malware-removal-plugin/webscan/) to detect malicious code and hidden redirects.