WP_Debug

WP_Debug

This is a really simple and quick tutorial on how to utilize WP_DEBUG for debugging and troubleshooting WordPress. It requires that you have access to your host files. 

Wp_Debug

WP_DEBUG is a setting in the wp-config.php file of your WordPress install that allows you to turn on and off error messages. Together there are three separate settings that define the debug level of your WordPress install. 

  • WP_DEBUG: Defines whether errors will be displayed on the site and controls whether or not errors should be recorded. This will display errors to the frontend of your site if WP_DEBU_DISPLAY is not set or if it is set to true.
  • WP_DEBUG_LOG: Defines if errors should be logged to the debug.log file located in the wp-content directory of your WordPress install. This setting does not display errors to the frontend of your site.
  • WP_DEBUG_DISPLAY: Defines if errors should be displayed to the frontend of your site. 

How does this work? Setting WP_DEBUG to true enables error recording in WordPress, by default if WP_DEBUG is set to true, errors will be displayed to the frontend of your website. This can be overridden though by setting WP_DEBUG_DISPLAY to false. Enabling WP_DEBUG_LOG will log all errors to the debug.log file located in the wp-content directory of your WordPress install. To utilize either WP_DEBUG_LOG or WP_DEBUG_DISPLAY, WP_DEBUG must be set to true.

For instance:

							
							
					# No error recording or error logging
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', false);
define('WP_DEBUG_DISPLAY', false);

# Error recording only as WP_DEBUG_DISPLAY and WP_DEBUG_LOG are set to false errors will not be displayed to the frontend nor will they be logged to debug.log
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', false);
define('WP_DEBUG_DISPLAY', false);

#Error recording and error logging to debug.log are enabled, errors will not be displayed to the frontend
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

#Error recording, error logging, and error display are enabled
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);				
			

I recommend only enabling WP_DEBUG when you are troubleshooting an issue in WordPress as displaying errors to the frontend should be done only in extremely rare instances, and security solutions such as WordFence will warn you against keeping an error log in the wp-content directory as it could be potentially accessible to the public.  The default activity of WordPress is to set WP_DEBUG to false and that is what I recommend as well when you aren’t debugging issues in WordPress.

That’s a wrap! I hope this post helps you debug many of your WordPress problems! Thanks for reading!

Walter Miely is a tech entrepreneur and CEO of Phoenix Ignited Tech You can find him on Linkedin. This material is licensed under the CC BY 4.0 License LEGAL DISCLAIMER: The content provided here is provided AS IS, and part of, or the entirety of this content may be incorrect. Please read the entireLegal Disclaimer here.