Finding PHP errors with WP_DEBUG, WP_DEBUG_LOG, and Query Monitor

In most cases, we are quite quick in identifying the cause of an issue that you report to us. However, there is still a chance that bugs occur because of a conflict with another plugin or a server setting.

These kinds of problems don’t show an error message on many setups by default. So to learn more, you can try to switch on the WordPress debug mode. It will log or display errors in PHP, the main language used to develop WordPress and Advanced Ads.

If you want to check for PHP errors yourself or I asked you to send me a list of PHP errors, use one of the methods described in this post.

  • using the Query Monitor plugin
  • using WP_DEBUG
  • using WP_DEBUG_LOG

Query Monitor


The free Query Monitor plugin helps webmasters to analyze page requests in the frontend and backend. Among the many useful reports, it will also tell you about critical PHP issues.

Once installed and enabled, you will see a new item in the toolbar at the top. It shows a red warning as soon as it detects a critical (PHP) issue.

QM tells you details about the PHP issue, too. Don’t worry. Advanced Ads is fine. I broke it on purpose to create this example.

Query Monitor does not create a log on its own. If you see a warning that might relate to Advanced Ads, please attach a screenshot of the PHP Errors tab and a copy of the text to an email and send it to me.

Bonus tip for developers: Check out profiling and debugging with Query Monitor.

See Also  How To Clean A Sand Point Well


“WP Debug” is a method to display or log PHP errors that would otherwise stay hidden. To enable it, you need access to the files on your server. Use “WP DEBUG LOG” to display the errors and log them to a file that you can inspect later.

Debug WordPress by following the steps below if you want to catch and log errors over time, especially when you are not sure how to trigger them directly.

1. Open wp-config.php

Log in to your FTP account and search for the wp-config.phpfile in your WordPress installation’s root directory.

Download the file and open it on your computer or edit it online (depending on your FTP editor).

2. Check for WP_DEBUG

Go down to the line where WP_DEBUG is defined. It normally looks like this:

define( 'WP_DEBUG', false );

If the line is missing, search for the comment that says /* That’s all, stop editing! Happy blogging. */.

We are going to insert new code above that line.

3. Insert WP_DEBUG codes

You have two options now. Either display all errors to the frontend or log them in a file so that no one sees them while visiting the page.

This is the code that you should include in your wp-config.php file to display and log all errors:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
@ini_set('display_errors', E_ALL);

It is obvious that you shouldn’t display the errors on a website that is already live and visited by (many) real users.

In order to log the errors without displaying them, insert this code block instead.

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Please save the file now. If you downloaded it before, upload it again to replace the existing version.

See Also  How to tune a kalimba

4. Provoke the error

Now go to the page where the problem happens. It can be the frontend or a page in the admin panel. If you performed a specific action, e.g., sending a form, then also do it now.

If you opted for the frontend output and want to let me know about an error message, please make a screenshot of the visible behavior.

5. Disable WP_DEBUG

Now go back to your wp-config.php file and disable WP_DEBUG. You can also decide to keep it on if you are working on a development environment or keep the logging for a while to catch bugs with other plugins or themes that you might not know, yet.

However, if you want to disable error output again, change WP_DEBUG to false, like in the line below.

define('WP_DEBUG', false);

And remove this line if you included it before.

@ini_set('display_errors', E_ALL);

Please save the file again.

6. Download debug.log

Go back to your FTP account and search for the wp-content folder in the root folder of your WordPress installation.

There should be a file called debug.log. If there isn’t, there could be two reasons:

  • there was simply no error
  • you don’t have permission to create new files. In this case, create an empty file called debug.log and upload it. Set the file permissions to 777.
  • If the file was created then download it.

    7. Check for errors

    Open debug.log now and check for errors. If I asked you to check this file, then you can also send it to me right away.

    Please be aware that the file contains PHP errors caused by any plugin, theme, or custom code. This could make it quite long over time.

    See Also  how to select all text in powerpoint

    You found an error related to Advanced Ads if one of the paths mentioned in an error message contains the string advanced-ads.

    You can find the official and detailed documentation about WP_DEBUG in the WordPress documentation.

    Rate this post
    Back to top button