Wp_debug
- WPDEBUG is a PHP constant (a permanent global variable) that can be used to trigger the “debug” mode throughout WordPress. It is assumed to be false by default and is usually set to true in the wp-config.php file on development copies of WordPress. // This enables debugging. Define ('WPDEBUG', true); // This disables debugging.
- WPDEBUG is set to true when the plugin is first run, thereafter it can be turned off in the Settings. The Settings page allows the user to set the following.
- WPDEBUG is a PHP constant (a permanent global variable) that can be used to trigger the 'debug' mode throughout WordPress. It is assumed to be false by default and is usually set to true in the wp-config.php file on development copies of WordPress. For information on other debugging tools built into WordPress see Debugging in WordPress.
- Enable debug errors in WordPress WordPress has a specific debug system and standardized code across the core, plugins, and themes to simplify the process of identifying PHP errors. Enabling this debug mode will cause all PHP errors and warnings to display, so you can find out what's wrong with your site.
From conflicts between WordPress plugins to poorly coded themes and mistakes in custom coding, several problems sound the alarm with website error codes and warnings. Even if you’re not sure what the warnings mean, you must fix them. The first step is learning how to set up a WordPress error log.
Debug mode is highly useful in troubleshooting a WordPress site that is showing errors or not working correctly. Enabling debug will help you identify the cause of the issue. This article will walk you through how to enable debug using the WP-config file.
As a short explanation, a WordPress error log is exactly what it sounds like: a list of error codes and times that occur on your website.
In this post, we’ll show you how to set up and work with WordPress error logs using the built-in WordPress debug mode.
When should you set up a WordPress error log?
Consider setting up a WordPress error log in the following situations:
- When you see a blank screen while trying to load your website.
- When a warning with an error code (401, 404, 500, etc.) appears.
- If your entire site crashes.
- If you’re noticing slow website performance.
- If a plugin or theme isn’t working properly.
- If you’re curious as to which plugins or themes are causing performance issues.
How to set up a WordPress error log
As is often the case with WordPress, you have two routes to enable error logging with WordPress debug mode:
- Manually
- With a plugin
We’ll start by showing you the manual method, which just involves adding a few code snippets to your site’s wp-config.php
file.
Then, if you want an even simpler option for error logging, we’ll share a free plugin that can get the job done.
Here’s how to do it manually…
Click here if you’d rather jump to the plugin 👈
Step 1: Access and edit the wp-config.php file
If you’re not familiar with your wp-config.php
file, it’s one of the core files for holding important configuration details, like the credentials for your site’s database.
To access the wp-config.php
file, either download and use an FTP client or a file manager tool in your host’s cPanel.
How to use FTP to connect to WordPress 👈
For this tutorial, we’ll cover the steps to access and edit your wp-config.php
file with an FTP client.
In your FTP client, locate the wp-config.php
file. This is normally in the root site directory.
Upon finding the file, right-click on it and select to edit or view the file. You’ll want to open the file in a text editor.
Step 2: Add a line of code in the wp-config.php file to turn on debug mode
Inside your text editor, search for a line of text that reads Stop editing! Happy blogging
.
Place your cursor on the empty line above that line of text.
Paste in the following code:
If you already notice this line of code in the file, it may currently be set to false
. If that’s the case, switch it to true
.
Afterward, save the file to your computer and upload the wp-config.php
file as an update to your website. This is done through the FTP client.

Great! Now debugging mode is activated for your WordPress site.
Step 3: But wait! I don’t want the errors to show on the frontend of my website
If you took a moment to check your dashboard or the frontend of your site, you may have already seen WordPress errors listed for everyone to see. This may not seem like a big deal if they show up on the WordPress dashboard, but you definitely don’t want the warnings on the frontend.
Not only is publicly displaying errors confusing for your visitors, but it can also be a security risk because it gives them detailed information about your site.
In short, debugging mode is messy when activated by itself.
Therefore, we need to log the errors in WordPress so they are recorded but not publicly displayed.
To log your errors, go back to that exact same wp-config.php
file in the text editor.
Look at the debug code you recently pasted into the file. Paste the following new code on the empty line below the debug code:
Again, in some situations you might discover that the debug log code is already included. For that, simply make sure that the false
at the end of the code is changed to true
.
The first line tells WordPress to save error messages to a file called debug.log
. The second snippet tells WordPress not to publicly display error messages.
Now, your error messages will be safely saved in the log file, but neither you nor your visitors will have to see error messages while browsing your site.
For a second time, save the wp-config.php
file in your file editor and upload it back to your WordPress website.
How to use a WordPress error log plugin
If you don’t feel comfortable working directly with your site’s configuration file, you can also use the free WP Debugging plugin:
WP DebuggingCurrent Version: 2.9.2
Last Updated: March 5, 2021
As soon as you activate the plugin, it instantly activates WordPress debug mode and enables error logging. It also lets you control whether or not to display debug messages on your site by visiting Tools -> WP Debugging.
Checking your WordPress error logs
We’re assuming you already know the website pages that are alerting you of errors.
You must visit these pages now that the debugging log is configured and ready to store the errors.
Reconnect to your website files using the FTP client. You can also connect via your host’s cPanel.
Go to the /wp-content/
folder.
Open that folder and look for a file called debug.log
.
This is the file you created from the previous steps.
What should I do with this debug log file?
The debug.log
file is accessible by editing, viewing, or downloading the file. It’s similar to the previous steps, where you might either just preview the file to look at it or open it in a file editor to make changes and save it for later.
Overall, a debug log file is for reference, not for editing. Therefore, you have to sift through the list of errors and warnings to identify what’s wrong with your site, theme, plugins, or code.
For most people, the error log codes mean nothing. If anything, it’s closer to gibberish than English. However, you don’t want to forget about those errors.
Your resolution steps should go like this:
- You identify an error with the debug log.
- You find the error code.
- You look up what that error code means.
- You utilize a separate guide to fix that error.
How to fix issues that you discover in the error log

Unfortunately, there’s no one-size-fits-all approach to fixing problems that you might discover in your site’s error log.
However, we do have lots of existing posts on how to fix common WordPress errors:
If you’re still not sure how to fix the issues in your log file, you might want to hire a WordPress developer to do it for you – here are some tips to find the right developer.
Do you have any questions about how to set up a WordPress error log?
Even looking at bits of code feels intimidating for the average WordPress user.
The good news is that setting up a WordPress error log only takes two small snippets of code.
If you have trouble activating your WordPress error log, or questions on how to fix them, let us know in the comments below!
Free guide
5 Essential Tips to Speed Up
Your WordPress Site
Reduce your loading time by even 50-80%
just by following simple tips.
WordPress has a configurable debugging system that allows us to display as well as log PHP errors, notices, and warnings. Besides that, sometimes we need to debug the code by writing custom PHP data or messages in a log file.
This is particularly useful during in custom code, theme as well plugin development in WordPress. If something isn’t working as expected then we log inputs, intermediate values, messages, variables etc. and debug further.
Here, I’m explaining you a bit about WordPress debugging. Further, I’ve written a function to log custom messages or PHP data in the WordPress log file. Also, we aren’t displaying them to visitors or the browser. We are only writing them to a file for inspection.
Debugging in WordPress
WordPress offers five constants for debugging. Out of them, we’re using three PHP constants here. They are WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY. Further, all of these three constants are placed in the wp-config.php file. Let us discuss each in context to writing custom data.
Are you using Bootstrap with WordPress? Don’t miss awesome pagination, page break, multi-column menu, and a better search box with dropdown as well.
WP_DEBUG
WP_DEBUG is a PHP constant that can enable the “debug” mode throughout WordPress. It’s the first constant you need to set true in the wp-config.php file. If the constant is already there then change “false” to “true” (without parenthesis).
WP_DEBUG_LOG
This is a companion to WP_DEBUG. Further, it causes all errors or your messages to be written to a debug.log log file. WordPress creates this file inside the wp-content directory and write logs there. We will log our custom data along with PHP errors, notices, and warnings in the same file. So you need to set WP_DEBUG_LOG to true in the wp-config.php as well.
WP_DEBUG_DISPLAY
Setting this constant to true will cause WordPress to display the error on the page in the browser. Further, true is the default value for this constant. That is alright in the development environment but seriously dangerous in the production. So for a live site, the recommended value of WP_DEBUG_DISPLAY is false.
Do you know what SEO tools and better tips we use to increase the traffic that nobody else will tell?
Setting WordPress Debugging Constants
Putting all them together, add the following lines of code in the wp-config.php file to enable debugging and logging. If these constants are already present then update their values as given.
1 3 | define('WP_DEBUG',true); define('WP_DEBUG_DISPLAY',false); |
Note that if WP_DEBUG is false then neither the logging nor the displaying will work despite its constant’s value. Also, it is better to enable writing in the debug.log only for the production environment. Additionally, once you have fixed the code, set WP_DEBUG back to false.
How much do you know WordPress? Check the constantly updated article.
Writing Custom PHP Data to debug.log
You can use PHP’s error_log() function in conjunction with WP_DEBUG constant to write custom data or messages. Add the following line of code in your plugin’s file or theme’s functions.php.
1 3 5 7 9 | if(!function_exists('write_my_log')){ functionwrite_my_log($log){ error_log( is_array( $log ) is_object( $log ) ? print_r( $log, true ) : $log ); } } |
And call the function like this below as much as you need:
1 3 5 7 9 | //Write a string write_my_log($_REQUEST); //A custom message with a variable write_my_log('The version number is: '.$version_number); |
How To Disable Wp_debug
Also, you would need some string assignment to log a boolean variable as shown in the example below:
1 | write_my_log($bool_var?'true':'false'); |
Wp_debug_log Not Working
So it’s all about debugging in WordPress. Further, we have written custom messages or PHP data to the debug.log. While it’s quite useful to fix the code, it’s also worth mentioning that debugging isn’t to run on a live site.
However, sometimes the code works fine in a local server but fails on the production server. In such cases, you can debug by writing your custom log messages while hiding the same from visitors. Just don’t forget to disable debugging later. Happy coding and debugging!