Enable debug logging in WordPress

WordPress can write debug information to the page or a log file. This is disabled by default, but you can change your wp-config.php configuration file to enable debugging. The resulting debug information can be useful for diagnosing critical errors.

Requirements

These instructions require you to modify wp-config.php, a core configuration file with every WordPress installation. Review the following instructions to determine the best way for you to modify the file. Once you know how to modify the file, return to these instructions for the specific changes to make.

Definitions

There are three Boolean settings you can define in wp-config.

// Enable core debugging (true or false)
define( 'WP_DEBUG', true );

// Log errors to wp-content/debug.log (true or false)
define( 'WP_DEBUG_LOG', true );

// Hide errors from being displayed on the site (true or false)
define( 'WP_DEBUG_DISPLAY', false );

If WP_DEBUG is false (or not defined), the other debug settings are ignored. You must set WP_DEBUG to true for other settings to take effect. Once you have set WP_DEBUG to true, you can control the output in two ways:

  • Set WP_DEBUG_LOG to true to write information to a text file located at wp-config/debug.log. This file will grow larger over time, so be sure to delete the file when finished.
  • Set WP_DEBUG_DISPLAY to true to write debug information to the page output. Be aware that visitors will see the information, and the information may contain sensitive data useful to hackers (such as paths, database names, etc.). Normally you want to keep this value as false unless you have no other choice.

Don’t forget to undo when finished

When finished, be sure to reset WP_DEBUG to false.

  • The debug information may contain sensitive information useful to hackers.
  • The debug information may impact performance.
  • The debug information, if displayed on the page, will be ugly to visitors.
  • The debug information, if written to a log file, will take up a lot of disk space.

When disabling debugging, you do not need to reset WP_DEBUG_LOG or WP_DEBUG_DISPLAY as they are ignored if WP_DEBUG is false.

See also

References

License

Licensed under CC BY 4.0 You are free to share and adapt this content for any purpose as long as you give appropriate credit in a reasonable manner.

No affiliate links

We do not participate in affiliate marketing, and we are not paid to mention products.

Leave a Reply

Your email address will not be published. Required fields are marked *