Debugging in WordPress is annoying. It’s turned off by default, and there’s no GUI for viewing the errors. Turning it on requires you to add lines to the wp-config.php file – something not everyone is comfortable doing, particularly given that it’s so sensitive and can easily destroy your entire site if you’re not careful. As a result, many WordPress errors and warnings go unnoticed until one day the whole thing crashes. What’s needed is an easy way to view debug info via the GUI without messing around with modifying core configuration files, and without needing to open a debug file. We need a proper, integrated GUI solution.
WP_DEBUG and WP_DEBUG Constants
To enable debugging in WordPress, you need to add the following constant to wp-config.php:
define( 'WP_DEBUG', true );
By default, this constant is set to “false”. This means that WordPress neither generates nor displays error messages. The problem, however, with setting this value to “true”, is that the error messages and warnings display in the page HTML. Which is a very bad thing for your viewers. Even worse if an attacker gets valuable information about your site through an error message.
To suppress these messages in the HTML, we need to set the WP_DEBUG_DISPLAY constant to “false” like this:
define( 'WP_DEBUG_DISPLAY', false );
But now how do we view the error messages! WordPress allows us to stream these to a debug log file using the statement:
define( 'WP_DEBUG_LOG', true );
This will create a file in the wp-content directory called “debug.log”, which we can then read. The problem arises when we forget about it, and it just keeps growing and growing…
Enter the WP Debug Log Plugin
Today I came across a new WordPress plugin called the WP Debug Log – Config Tool that does the following:
- Allows you to turn debugging on and off with a simple click
- Allows you to stream the debug messages to a file
- Shows you the debug messages on a GUI screen
- Lets you clear the log file and also gives you the correct size
All from within the WordPress administration dashboard. Easy! Here’s a screenshot of the options screen:
By default, all three options are turned on. I suggest you disable the third one called “SCRIPT_DEBUG” since it has a very specific use-case scenario involving modifications to native libraries. The first two options, however, enable debugging and create a log file with the error. You can turn these options on and off whenever you want and save your changes. No need to access the wp-config.php file anymore!
The second value-add of the plugin comes when it allows you to see the debug logs in the next section as shown here:
Because of this, there’s no need to fire up a file manager, download the debug log file, and open it in a text editor. Instead, you can just see the complete error message in the WordPress dashboard. It also tells you the size of the log file and lets you clear it before it gets too large.
In all this is a simple tool that accomplishes an important task – namely allowing you to keep track of warnings and errors in WordPress without having to make any configuration changes that can accidentally break your site. As a side benefit, the plugin also allows you to create constants in WordPress. Probably you won’t be using this unless you know what you’re doing!
You don’t even need to keep this plugin active permanently. Just activate it whenever you’re making some changes, and need to check the error messages. Do your work, and then deactivate it. Perfect for those who don’t want to clutter up their site with unnecessarily active plugins!
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Leave a Reply