Skip to content

WordPress WP_DEBUG Code Generator for wp-config.php

Turn on the debug log without breaking your live site

Runs in your browser. Nothing is uploaded.

Where is this site?

This changes the verdict below, not the code. Errors printed on screen are fine on your own machine and unsafe on a live site.

Verdict

—

Options
wp-config.php

Paste these ABOVE the /* That's all, stop editing! */ line. The require_once line below it loads WordPress, which reads these constants as it starts, so lines placed under it come too late. In our test on WordPress 7.1.4 and PHP 8.3, WP_DEBUG_LOG added below that line had no effect. Before you paste, delete any line that already defines one of these constants: a new wp-config.php has define( 'WP_DEBUG', false ); a few lines above that spot, and PHP keeps the first value. In our test (PHP 8.4.5) the pasted block then left WP_DEBUG false, with the warning "Constant WP_DEBUG already defined". WordPress reads WP_DEBUG_LOG only when WP_DEBUG is true, so no log is written.

About the WordPress WP_DEBUG Code Generator for wp-config.php

Generate the WP_DEBUG lines for wp-config.php that write PHP errors to a log file instead of showing them to visitors, with a verdict on whether it is safe.

Tick the options you need and copy the lines into wp-config.php. The verdict box above the options says whether that combination is safe on a live site. For what WP_DEBUG, WP_DEBUG_LOG and WP_DEBUG_DISPLAY each do, and how to switch debug mode off again, read the WordPress debug mode guide.

Worked example: log errors on a live site

Input: the defaults.

Where is this site?                           Live site
WP_DEBUG                                      on
WP_DEBUG_LOG                                  on
WP_DEBUG_DISPLAY false                        on
Write the log to the folder above WordPress   off
SAVEQUERIES                                   off
SCRIPT_DEBUG                                  off

Output, from running the tool's own script in Node.js with that input on 16 November 2026. The verdict box read "OK on a live site, for a short while".

/**
 * Generated at odiethemes.com/tools/wordpress-debug-log
 * Paste ABOVE the "That's all, stop editing!" line in wp-config.php.
 * First delete any line in the file that already defines one of these
 * constants. A new wp-config.php has define( 'WP_DEBUG', false ); a few
 * lines above that spot. PHP keeps the first value and ignores the second.
 */

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );  // -> wp-content/debug.log
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );  // WordPress sets display_errors off too, but only once it starts loading

Line by line (the behaviour is read from wp_debug_mode() in the WordPress 7.1.4 source; the tests are noted where we ran them):

  • The block at the top is a PHP comment. It quotes the "stop editing" line without its /* */ markers on purpose: PHP comments do not nest, so a second */ inside it would end the comment early and break wp-config.php.
  • The comment also says to delete the WP_DEBUG line your file already has. A new wp-config.php (wp-config-sample.php in WordPress 7.1.4) has define( 'WP_DEBUG', false ); a few lines above the "stop editing" line. We pasted this output under it and ran the file with PHP 8.4.5 on 16 November 2026: WP_DEBUG stayed false and PHP warned "Constant WP_DEBUG already defined". WP_DEBUG_LOG was true, but WordPress reads it only when WP_DEBUG is true, so no log would be written.
  • WP_DEBUG true makes WordPress tell PHP to report every kind of error, notices and deprecation messages included. With it off, WordPress leaves those two out.
  • WP_DEBUG_LOG true makes WordPress point PHP's error log at wp-content/debug.log. The file only appears once something is logged: in our test (WordPress 7.1.4 and PHP 8.3 in WordPress Playground, November 2026), eight normal page loads left no file, and the first warning created it.
  • WP_DEBUG_DISPLAY false makes WordPress turn PHP's display_errors off, so visitors see no messages. Its default is true, which is why WP_DEBUG on its own prints errors into the page.
  • @ini_set( 'display_errors', 0 ) covers the moment before WordPress applies the line above, while wp-config.php itself is still running. The WordPress handbook's own example pairs the two lines the same way.

The verdict says "for a short while" because the WordPress handbook recommends debugging on a local or staging copy. On a live site, find the problem and then set WP_DEBUG back to false.

When you need it

Use it when something breaks and WordPress does not say why: a white screen, a "critical error" message, or a plugin that stops saving its settings. With WP_DEBUG off, PHP skips notices and deprecation messages, and whether anything else is recorded depends on your host's PHP settings.

Reading the log

  1. Open wp-config.php and delete the line define( 'WP_DEBUG', false ); (a new wp-config.php has it a few lines above "That's all, stop editing!"), and any other line that already defines one of these constants. Then paste the lines above the "That's all, stop editing!" line.
  2. Load the broken page again, so the error happens while logging is on.
  3. Open wp-content/debug.log and read the newest lines at the bottom. Each one starts with a time in UTC, because WordPress sets PHP's clock to UTC, so it may not match the timezone in your settings. Nothing in WordPress core empties the file; in our test a second error was added below the first.
  4. Paste a "PHP Fatal error" entry into the PHP fatal error decoder to see which plugin or theme it points to.

If the file is missing or stays empty, the debug.log location guide covers hosts that write it somewhere else.

Moving the log out of the web root

wp-content/debug.log sits inside the web root, and Site Health reports "Your site is set to log errors to a potentially public file" when it is in use. Ticking "Write the log to the folder above WordPress" changes the log line to this (tool output, unchanged):

// wp-content/debug.log is inside the web root, so a server that does not
// block it hands the file to anyone who requests its URL. This writes the
// log to the folder above WordPress instead. That is outside the web root
// only if WordPress sits at the root, and PHP must be able to write there.
define( 'WP_DEBUG_LOG', dirname( ABSPATH ) . '/wp-errors.log' );

Site Health then lists the log as a recommendation rather than a critical issue: it only checks whether the log path starts with the WordPress folder (class-wp-site-health.php in WordPress 7.1.4). If WordPress sits in a subfolder of your site, the folder above it is still public, so the file is not safe there.

The line can use ABSPATH because wp-load.php defines it before it loads wp-config.php. We read that from the WordPress 7.1.4 source; our custom-path test used a fixed folder, not this exact line.

WordPress has accepted a file path in WP_DEBUG_LOG since version 5.1. The folder must already exist and PHP must be allowed to write to it. In our test, a path into a missing folder logged nothing and showed no error, so check that a test error really reaches the new file.

Common mistakes

  • Writing 'false' in quotes. A quoted 'false' is a non-empty string, which PHP treats as true. In our tests a quoted 'false' for WP_DEBUG still wrote the log, and a quoted 'false' for WP_DEBUG_DISPLAY still printed errors on the page.
  • Leaving the old define( 'WP_DEBUG', false ); in the file. PHP keeps the first value of a constant, so a second define further down is ignored: in our test WP_DEBUG stayed false and PHP warned "Constant WP_DEBUG already defined".
  • Pasting the lines below "That's all, stop editing!". The require_once line under that comment loads WordPress, which reads these settings as it starts. In our test a WP_DEBUG_LOG line placed below it had no effect.
  • Using WP-CLI without --raw. wp config set WP_DEBUG_DISPLAY false writes the string 'false'; wp config set WP_DEBUG_DISPLAY false --raw writes the boolean. We checked both with WP-CLI 2.12.0.
  • Leaving SAVEQUERIES on. It keeps every database query of every request in memory, and the handbook says to turn it off when you are not debugging.

Limits

  • The tool writes configuration lines. It cannot read your log, and it cannot see whether your host overrides PHP's error_log or display_errors settings.
  • An error in wp-config.php itself, such as a missing semicolon, happens before WordPress turns its log on, so it never reaches debug.log. In our test, a parse error in wp-config.php left no debug.log, while the same settings logged a parse error in a plugin. Look in the server's own PHP error log for those.
  • The verdict judges the options you ticked, not your server. It does not check whether your server blocks requests to debug.log.

Sources

Guides for this tool

FAQ

Questions

Is it safe to enable WP_DEBUG on a live site?

Only with WP_DEBUG_DISPLAY set to false. WP_DEBUG_DISPLAY defaults to true, and while it is true WordPress turns PHP's display_errors on, so notices and warnings, with your server's file paths, are printed into the pages visitors load. Pair WP_DEBUG with WP_DEBUG_LOG and WP_DEBUG_DISPLAY false, and keep it on only while you look for the problem: the WordPress developer handbook recommends debugging on a local or staging copy, not on a live site.

Where does the WordPress debug log go?

wp-content/debug.log by default, and the file only appears once something is logged. That folder is inside the web root, and the Site Health screen warns that a log there may be public. You can give WP_DEBUG_LOG a file path outside the web root instead. The folder must already exist: in our test on WordPress 7.1.4 and PHP 8.3 (WordPress Playground, November 2026), a path into a missing folder logged nothing and showed no error.

I set WP_DEBUG to true and nothing happened. Why?

First check where the line is. It must sit above "That's all, stop editing!" in wp-config.php: the require_once line under that comment loads WordPress, which reads the debug settings as it starts. In our test on WordPress 7.1.4 and PHP 8.3 (WordPress Playground, November 2026), a WP_DEBUG_LOG line placed below it had no effect. Then check that the file does not define WP_DEBUG twice. A new wp-config.php already has define( 'WP_DEBUG', false ); a few lines above that spot, and PHP keeps the first value: in our test with PHP 8.4.5 (16 November 2026), a second define further down was ignored, with the warning "Constant WP_DEBUG already defined". Delete the old line. If both are right, a blank screen may be correct: with WP_DEBUG_DISPLAY false the errors go to wp-content/debug.log, and that file only appears once something has been logged.