The WordPress debug log: how to turn it on, find it and read it

By CompatNav · Published · Last reviewed · 5 min read

Short answer

Add three lines to wp-config.php, above the line that says to stop editing: WP_DEBUG and WP_DEBUG_LOG set to true, WP_DEBUG_DISPLAY set to false. WordPress then writes PHP’s errors, warnings and notices to wp-content/debug.log (or a file you choose) instead of showing them on your pages. No file? Usually WP_DEBUG is defined a second time further up, the lines are below the stop-editing comment, or nothing has gone wrong yet. Turn it off again when you’re done.

Turn it on without showing errors to visitors

WordPress’s documentation gives these lines for wp-config.php, the configuration file in your site’s main folder:

wp-config.php · configuration from the WordPress documentation, tested on WordPress 7.1.2

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

The documentation says what they do: they “log all errors, notices, and warnings to a file called debug.log in the wp-content directory. It will also hide the errors, so they do not interrupt page generation.” And where they go: “You must insert this BEFORE /* That’s all, stop editing! Happy blogging. */ in the wp-config.php file.” (developer.wordpress.org) The comment has changed over the years: in WordPress 7.1.2’s sample file it reads “That’s all, stop editing! Happy publishing.”, and the line above it says: “Add any custom values between this line and the “stop editing” line.” (WordPress 7.1.2 source)

New to wp-config.php? How to edit it safely
  1. Make a copy first. Download the file, or duplicate it, so you can put it back if something goes wrong.
  2. Open the file. In your hosting control panel, open the File Manager and go to your WordPress folder (often called public_html). wp-config.php is usually there, next to the wp-admin and wp-content folders. You can also use an FTP program with the FTP details your host gives you.
  3. Find the right place. Add new lines above the line /* That's all, stop editing! Happy publishing. */ (on older sites it ends with “Happy blogging”). If a line with the same name is already there, for example define( 'WP_DEBUG', false );, change that line instead of adding a second one.
  4. Save, then reload your site. If it shows an error, put your copy back.

Not comfortable doing this? Ask your host’s support to make the change; it’s a routine request.

Where the log file is

“When set to true, the log is saved to debug.log in the content directory (usually wp-content/debug.log) within your site’s file system. Alternatively, you can set it to a valid file path to have the file saved elsewhere.” (developer.wordpress.org)

A file in wp-content sits in the public part of your site, and on many servers anyone who knows its address can open it. A path outside the web folder avoids that. Your host can tell you which folder is safe:

wp-config.php · from the WordPress documentation; the path is an example, use one your host confirms

define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' );

Open the file with your hosting panel’s File Manager or by FTP, and read it from the bottom: the newest entries are last.

debug.log not created? The usual causes

  1. WP_DEBUG is defined twice. WordPress’s own sample wp-config.php already contains define( 'WP_DEBUG', false );. If you add your lines lower down without removing that one, the first definition wins and debug mode stays off. Change the existing line instead of adding a new one.
  2. The lines are below the stop-editing comment. Move them above it.
  3. true is in quotes. The documentation warns: “If you set constants to ‘false’, they will be interpreted as true because the quotes make it a string rather than a boolean.” Write true and false without quotes, so you always know what you get.
  4. WP_DEBUG is off. “for WP_DEBUG_LOG to do anything, WP_DEBUG must be enabled (true).” (developer.wordpress.org)
  5. Nothing has gone wrong yet. The file appears with the first message. Visit the page with the problem, then look again.
  6. The server can’t write there. If none of the above helps, ask your host whether PHP may create files in wp-content, or use a path they give you.

The first cause is easy to miss, because PHP only warns and keeps the first value:

PHP 8.5: the second definition is ignored, so WP_DEBUG stays false.

wp-config.php

<?php
define( 'WP_DEBUG', false ); // already further up in wp-config.php

// ... added later, lower down:
define( 'WP_DEBUG', true );

echo 'WP_DEBUG is ', var_export( WP_DEBUG, true ), "\n";

Output on PHP 8.5.11

Warning: Constant WP_DEBUG already defined, this will be an error in PHP 9 in /var/www/html/wp-config.php on line 5
WP_DEBUG is false

How to read an entry

Each entry is one message from PHP: what went wrong, then the file and line. This is a real fatal error, from a plugin that still uses a function PHP 8.0 removed:

Output on PHP 8.0.30the script stopped

Fatal error: Uncaught Error: 1Call to undefined function create_function() in /var/www/html/2wp-content/plugins/old-slider/includes/slider.php:3
Stack trace:
#0 {main}
  thrown in /var/www/html/wp-content/plugins/old-slider/includes/3slider.php on line 3
  1. What went wrong: PHP can’t find create_function(), because PHP 8.0 removed it.
  2. Which plugin: the folder after wp-content/plugins/ (or wp-content/themes/): here, old-slider.
  3. Where exactly: the file and line, for whoever fixes the code.

In the log file, each entry also starts with the date and time, and the kind of message with “PHP” in front, for example [01-Oct-2026 17:53:48 UTC] PHP Warning: (from our test site, WordPress 7.1.2). Three kinds of message matter most:

  • Fatal error: the page stopped. Fix these first; the critical error guide shows how.
  • Warning: something went wrong, but the page carried on.
  • Deprecated: works today, but a future PHP version will change it. Not urgent; the plugin’s next update usually fixes it. What each level means is in deprecation notice vs fatal error.

Search the log for the plugin’s folder name to see everything one plugin caused. Some messages only appear on certain pages or with certain data, such as “count(): Argument #1 ($value) must be of type Countable|array”: keeping the log on for a few days after a PHP update catches them.

When you’re done

The documentation is clear: “It is not recommended to use WP_DEBUG or the other debug tools on live sites; they are meant for local testing and staging installs.” (developer.wordpress.org) Once you’ve found the problem, set WP_DEBUG back to false and delete the log file.

Key takeaways

  • Three lines in wp-config.php: WP_DEBUG true, WP_DEBUG_LOG true, WP_DEBUG_DISPLAY false. They must go above the “stop editing” comment.
  • The log is wp-content/debug.log, or the file path you give WP_DEBUG_LOG. A path outside the public web folder keeps it private.
  • No log file? Check for a second define( 'WP_DEBUG', … ), lines placed too low, 'true' in quotes, or simply no error yet.
  • Each entry names the problem, then the file and line: the folder after wp-content/plugins/ or wp-content/themes/ is the culprit.
  • WordPress advises against debug mode on live sites: use it briefly, and turn it off when you’re done.

Frequently asked questions

Where is the WordPress debug log?

In wp-content/debug.log, once WP_DEBUG and WP_DEBUG_LOG are on and something has been logged. If WP_DEBUG_LOG is set to a file path instead of true, the log is at that path.

Why is debug.log not created?

The usual causes: WP_DEBUG is defined twice and the first definition (often false) wins; the lines are below the “stop editing” comment; true is written in quotes; nothing has been logged yet; or the web server can’t write to the folder, in which case ask your host.

Is it safe to keep the debug log on?

WordPress advises against debug mode on live sites. If you need it to find a problem, keep the display off, write the log outside the public web folder, and turn debug mode off again when you’re done.

My host has its own error log. Do I need this one?

Not always. Many hosting panels show PHP’s error log; it contains the same kind of messages. The WordPress debug log is useful when you can’t reach that one, or want WordPress’s own deprecation notices too.

Check your own site before you upgrade

CompatNav is a free WordPress plugin. It reads the code of your plugins and themes on your own server and tells you, in plain words, what will break and what will only show notices on the PHP version you choose. It never changes your code. It can’t see problems that only appear while code runs with real data, so a quick check of your site after the upgrade still matters.

Get CompatNav on wordpress.org How it works

Sources

About the code examples: each output is the real output of the code shown, run with the official PHP builds, without a php.ini, with all errors reported and displayed. Only the file path was replaced by a neutral server path.