Debugging & Profiling

debug.log Not Created or Not Updating: Every Reason WordPress Stays Silent

debug.log not created? Check WP_DEBUG, defines below the stop-editing line, permissions and host locks: 13 causes with fixes, plus keeping the log private.

Varun DubeyVarun Dubey
·15 min read
Terminal showing tail: cannot open debug.log, No such file or directory, beside the title debug.log not created?

If your debug.log is not created, the cause is almost always one of three things: WP_DEBUG is not actually true, the constants sit below the require_once ABSPATH . 'wp-settings.php'; line in wp-config.php, or PHP cannot write to the folder the log should go in. Check those first. If all three are fine, this page walks through thirteen causes in all, each with the symptom, the check and the fix, then covers the problem nobody checks: a debug.log that works perfectly and is readable by anyone on the internet.

We reproduced causes 1 to 10 on a clean WordPress 7.1.3 install running PHP 8.3 on Apache 2.4.68 before writing them down. Causes 11 to 13 are documented behaviour that we checked against the WordPress developer handbook, WordPress core source and the PHP manual on 15 November 2026; they were not part of that test run. Constants, commands and config lines below were checked on 15 November 2026.

Why is debug.log not created even though WP_DEBUG_LOG is true?

WordPress never creates the file itself. It only tells PHP where to write, and PHP creates the file the first time something is logged. So the log can be missing because the setting is ignored, because nothing was logged yet, or because PHP is not allowed to write there. The table maps what you see to the section that fixes it.

What you see

Most likely cause

Go to

No file, and the constants look right

Defines below the wp-settings.php line, or a second define of WP_DEBUG

Causes 1 and 2

No file, custom path set

Folder missing or not writable

Causes 3 and 4

File exists but never grows

File owned by another user, or a plugin turned logging off

Causes 4 and 5

Blank page or critical error, log empty

Failure before WordPress sets up logging, or the host disabled ini_set

Causes 6 and 10

Errors appear on the page, no file

WP_DEBUG_LOG is not set

Cause 7

Nothing on screen and no file

No error has happened yet, or display is off and logging is blocked

Causes 11 and 12

You edited wp-config.php and nothing changed

Cached copy of the file, or you edited the wrong copy

Cause 13

How do I enable WP_DEBUG and debug.log in WordPress?

WordPress debug mode is off by default. The WordPress handbook says WP_DEBUG is assumed to be false unless you set it. To turn WordPress debug on, add the lines below to wp-config.php, above the line that says “That’s all, stop editing”. These are the handbook’s own examples:

// 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 );

What each line does:

  • WP_DEBUG switches debug mode on. Without it, the other two lines do nothing.
  • WP_DEBUG_LOG writes errors to debug.log in the content directory, usually wp-content/debug.log.
  • WP_DEBUG_DISPLAY controls whether errors print on the page. Its default is true, so setting it to false keeps errors off the screen while the log still collects them.

If you have WP-CLI, you can set the same constants without opening the file. The command below is the documented WP-CLI example, and --raw writes the value as true instead of the string “true”:

wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_LOG true --raw
wp config set WP_DEBUG_DISPLAY false --raw

The handbook says it is not recommended to use WP_DEBUG or the other debug tools on live sites. Use a local copy or staging. If you must look at a live problem, keep display off, log to a file, read it, then turn debug mode off again.

When you are done, set both constants back to false (wp config set WP_DEBUG false --raw) and delete the old debug.log, which can hold file paths and other details you do not want public.

The handbook also covers SCRIPT_DEBUG (loads the unminified core CSS and JavaScript, default false) and SAVEQUERIES (stores every database query in $wpdb->queries, with a performance cost), which have nothing to do with the log file and are not repeated here. If you have done the steps above and the log still does not appear, the rest of this page is for you.

What is the fastest way to find out why debug.log is missing?

Run these three commands from the WordPress root before reading anything else. They answer most cases on their own.

# 1. What does WordPress actually see for the debug constants?
wp config get WP_DEBUG
wp config get WP_DEBUG_LOG

# 2. Where is PHP really sending errors right now, for a web request?
wp eval 'echo ini_get("log_errors") . " | " . ini_get("error_log") . PHP_EOL;'

# 3. Can the web server user write where the log should go?
ls -ld wp-content
ls -l wp-content/debug.log 2>/dev/null || echo "no debug.log yet"

Note that wp eval runs in the CLI, which can use a different php.ini from your web server. If the CLI answer looks right and the browser request still logs nothing, the web server’s PHP settings are the place to look, which several sections below cover.

How does WordPress decide where errors go?

Every cause below makes sense once you have seen the code. WordPress sets up error logging in wp_debug_mode(), in wp-includes/load.php, very early in wp-settings.php (before the object cache drop-in, before any plugin). In WordPress 7.1.3 the important part reads:

if ( WP_DEBUG ) {
	error_reporting( E_ALL );

	if ( in_array( strtolower( (string) WP_DEBUG_LOG ), array( 'true', '1' ), true ) ) {
		$log_path = WP_CONTENT_DIR . '/debug.log';
	} elseif ( is_string( WP_DEBUG_LOG ) ) {
		$log_path = WP_DEBUG_LOG;
	} else {
		$log_path = false;
	}

	if ( $log_path ) {
		ini_set( 'log_errors', 1 );
		ini_set( 'error_log', $log_path );
	}
}

The official WordPress debugging documentation describes the constants; the code shows what they really do. The excerpt is trimmed to the logging part: the real function also sets display_errors from WP_DEBUG_DISPLAY and forces it off for AJAX, REST, XML-RPC and JSON requests (we re-read it in the core trunk on 15 November 2026), and it does not check that the log path exists or is writable. Three things follow from that block:

  • Nothing happens unless WP_DEBUG is true. WP_DEBUG_LOG on its own is ignored.
  • WordPress never creates a file or a folder. It only tells PHP where to write. PHP then tries to open that file on the first error, and if it cannot, it gives up quietly.
  • It runs once, early. Anything that changes log_errors, error_log or error_reporting later in the request wins.

What did we test, and what happened?

We ran each scenario on a fresh WordPress 7.1.3 container (PHP 8.3.35, Apache 2.4.68). A must-use plugin raised one warning per web request, tagged with a query string, so we could tell which request wrote which line:

<?php
// wp-content/mu-plugins/dbg.php
if ( PHP_SAPI === &#x27;cli&#x27; ) {
	return; // keep WP-CLI out of the results
}
trigger_error( &#x27;dbg-test &#x27; . ( $_GET[&#x27;t&#x27;] ?? &#x27;none&#x27; ), E_USER_WARNING );

Then for each scenario we reset the constants, loaded /?t=scenario-name once, and counted the matching lines in the log. Each scenario below is one reason the log stays empty, with how to recognise and fix it. The fourteen setups we ran covered causes 1 to 10, including three host-lock variants.

Reason 1: WP_DEBUG is false, so WP_DEBUG_LOG is ignored

Symptom: you set WP_DEBUG_LOG to true and nothing ever appears. Check: wp config get WP_DEBUG. Also search the whole file, because the default wp-config-sample.php already contains define( 'WP_DEBUG', false ); and it is easy to add a second definition below it:

grep -n "WP_DEBUG" wp-config.php

PHP keeps the first definition of a constant and ignores the second (with a warning), so whichever define() comes first wins. Fix: keep exactly one block, above the “stop editing” line:

define( &#x27;WP_DEBUG&#x27;, true );
define( &#x27;WP_DEBUG_LOG&#x27;, true );
define( &#x27;WP_DEBUG_DISPLAY&#x27;, false ); // log errors, do not print them on the page

This is also the usual reason for a confusing Site Health warning: one WordPress.org forum user saw “Your site is set to log errors to a potentially public file” with WP_DEBUG set to false near the top of the file, and found a second debug block further down that overrode it. Our list of wp-config.php constants shows where each one belongs.

Reason 2: the constants are below the wp-settings.php line

Symptom: the constants are clearly in wp-config.php and still have no effect. Check: look at where they sit. WordPress reads them when wp-settings.php runs, which is triggered by the last line of wp-config.php:

/* That&#x27;s all, stop editing! Happy publishing. */
require_once ABSPATH . &#x27;wp-settings.php&#x27;;

Anything defined after that line is defined too late; by then wp_debug_mode() has already run. In our test, the warning never reached the log with the defines appended at the bottom of the file. Fix: move them above the comment. Hosting control panels and some security plugins append settings to the end of wp-config.php, so check again after any of those touch the file.

Reason 3: a custom log path in a folder that does not exist

Symptom: you set a custom path and no file appears there. Since WordPress 5.1, WP_DEBUG_LOG accepts a file path instead of true (the 5.1 developer note says so), which is the right way to keep the log out of the web root. But WordPress only passes the path to PHP. It does not create missing folders, and PHP will not either.

Check:

wp config get WP_DEBUG_LOG
ls -ld "$(dirname "$(wp config get WP_DEBUG_LOG)")"

Fix: create the folder and give it to the user PHP runs as (often www-data, sometimes your account user on shared hosting):

mkdir -p /var/www/private-logs
chown www-data:www-data /var/www/private-logs
chmod 750 /var/www/private-logs

In our test the same path that logged nothing started working the moment the folder existed and was writable.

Reason 4: PHP cannot write the folder or the file

Symptom: everything is configured, there is no log, and there is no error about it anywhere. This is the most common cause on servers where files were uploaded by one user and PHP runs as another. Two variants failed silently in our tests:

  • wp-content was not writable by the web server user, so PHP could not create debug.log.
  • debug.log already existed but was owned by root with mode 644, so PHP could not append to it. This one is sneaky: you can see the file, it just never grows.

Check who PHP runs as and who owns the files:

# the user PHP runs as for web requests (create, load, then delete this file)
echo &#x27;<?php echo get_current_user() . " / " . posix_getpwuid(posix_geteuid())["name"];&#x27; > whoami-tmp.php
curl -s https://example.com/whoami-tmp.php; rm whoami-tmp.php

ls -ld wp-content
ls -l wp-content/debug.log

One more variant comes up on Red Hat, Rocky and Alma servers: SELinux can stop the web server writing to a folder even when the Unix permissions are right. Users on the forums report that setting the file to 777 changes nothing in that case. Check with getenforce and ls -Z wp-content; we did not test SELinux, so treat it as the next suspect only when ownership and mode are already correct. Our chmod guide for WordPress files and folders covers the normal permission values.

Fix: give the log file (or the folder it lives in) to the PHP user, rather than making wp-content world-writable:

touch wp-content/debug.log
chown www-data:www-data wp-content/debug.log
chmod 640 wp-content/debug.log

Reason 5: a plugin or theme switches logging off

Symptom: the log works on a fresh install or with plugins off, and stops when your plugins load. Because wp_debug_mode() runs before any plugin, a plugin that changes PHP’s error settings later in the request overrides WordPress. We reproduced both patterns that do this:

ini_set( &#x27;log_errors&#x27;, &#x27;0&#x27; ); // nothing is logged after this line
error_reporting( 0 );         // nothing is even reported, so nothing is logged

Plugins usually do this to hide notices from customers, which is understandable on production and maddening when you are debugging. Check: search for the culprit:

grep -rnE "error_reporting\(\s*0\s*\)|ini_set\(\s*[&#x27;\"](log_errors|error_log|error_reporting)" \
  wp-content/plugins wp-content/themes wp-content/mu-plugins

Then confirm by switching plugins off without touching the database, the safe way on a live site:

wp plugin list --status=active
wp plugin deactivate suspected-plugin
# reproduce the error, check the log, then:
wp plugin activate suspected-plugin

Fix: use the plugin’s own setting if it has one. Otherwise deactivate it while you debug, or ask its author why it silences errors. Errors raised before plugins_loaded cannot be rescued by a later hook, so deactivating is the reliable route.

Reason 6: the error happens before WordPress sets up logging

Symptom: the site shows a 500 error or “There has been a critical error”, and debug.log has nothing about it. In our test, a fatal error placed inside wp-config.php produced an HTTP 500 and no line in debug.log; the message went to the web server’s error log instead. That is expected: wp-config.php runs before wp_debug_mode(), so PHP is still using the server’s own settings.

The same applies to anything that fails before WordPress loads its settings: a syntax error in wp-config.php, a broken PHP prepend file, a missing PHP extension, or a server running out of memory before WordPress starts.

Check: the server’s own log. The PHP error handling settings (log_errors, error_log) decide where it is. Common locations:

tail -n 50 /var/log/apache2/error.log   # Apache, Debian/Ubuntu
tail -n 50 /var/log/nginx/error.log     # nginx
php -i | grep -E "^(error_log|log_errors)"

On managed hosting, the same log is usually in the control panel under “Logs” or “Error log”. If the failure is a blank screen, our white screen of death guide covers recovery steps.

Reason 7: WP_DEBUG is on but WP_DEBUG_LOG is not

Symptom: errors are clearly happening, WP_DEBUG is true, and there is no debug.log. With WP_DEBUG_LOG unset, WordPress does not change where PHP logs, so errors follow the server’s settings. In our test they landed in Apache’s error log, not in wp-content. Fix: add define( 'WP_DEBUG_LOG', true ); or a custom path.

Reason 8: you are looking at the wrong file

Symptom: the log you open is old or empty while errors keep happening. Find where PHP writes for a real web request, not the CLI: the error_log value printed by the snippet in Reason 10 is exactly that. If it is not your debug.log path, read that file instead.

Reason 9: something tells WordPress to skip its debug setup

The code above starts with a filter: enable_wp_debug_mode_checks. If it returns false, WordPress skips the whole block. Because it runs before plugins and the cache drop-in, only code that runs earlier can set it, in practice wp-config.php or a PHP prepend file. It is rare, but if every other check passes, search for it:

grep -rn "enable_wp_debug_mode_checks" wp-config.php wp-content/ 2>/dev/null

Reason 10: the host has locked PHP’s logging settings

Everything WordPress does here goes through ini_set(). On many shared and managed hosts, the server’s PHP configuration sets the logging values in a way ini_set() cannot change, and three variants behaved differently in our tests.

log_errors forced off with php_admin_flag

Settings made with php_admin_flag or php_admin_value (in the Apache or PHP-FPM pool config) cannot be changed by scripts, as the PHP manual on changing configuration explains. With php_admin_flag log_errors off on the server, WordPress’s ini_set( 'log_errors', 1 ) silently did nothing and no error was logged anywhere.

error_log pinned to the host’s own file

With php_admin_value error_log /var/log/php-site.log, the warning was written, just not to debug.log: it went to the host’s file. This is the common setup on managed hosting, where each site gets its own PHP error log in the control panel. If your debug.log stays empty on such a host, open the host’s PHP error log first.

ini_set disabled entirely

This one surprised us. With disable_functions = ini_set in php.ini and WP_DEBUG true, WordPress itself failed: every page returned HTTP 500 with the critical error screen, and the server log showed:

PHP Fatal error:  Uncaught Error: Call to undefined function ini_set()
in /var/www/html/wp-includes/load.php:617
#0 /var/www/html/wp-settings.php(85): wp_debug_mode()

In PHP 8, calling a disabled function is a fatal error, and wp_debug_mode() calls ini_set() as soon as WP_DEBUG is true. So on a host that disables ini_set, switching debugging on takes the site down. Set WP_DEBUG back to false to recover, then ask the host to allow ini_set or to give you their PHP error log.

Check what the server enforces, from a web request rather than the CLI:

<?php
// wp-content/mu-plugins/zz-php-locks.php (delete after one request)
add_action( &#x27;shutdown&#x27;, function () {
	if ( current_user_can( &#x27;manage_options&#x27; ) ) {
		printf(
			&#x27;<!-- log_errors=%s | error_log=%s | disabled=%s -->&#x27;,
			esc_html( ini_get( &#x27;log_errors&#x27; ) ),
			esc_html( ini_get( &#x27;error_log&#x27; ) ),
			esc_html( ini_get( &#x27;disable_functions&#x27; ) )
		);
	}
} );

If error_log shows a path that is not yours and does not change when you set WP_DEBUG_LOG, the host has pinned it. Read that file, or ask the host for access.

Reason 11: no error has happened yet

Symptom: everything is configured correctly and wp-content/debug.log still does not exist. Check: PHP creates the file when it writes the first line, so a site with nothing to report has no log. Force one line and look again:

wp eval 'trigger_error( "debug-log-test", E_USER_WARNING );'
ls -l wp-content/debug.log

Remember that wp eval runs in the CLI. If that line appears but a browser request logs nothing, the web server is running PHP with different settings, which Reasons 4, 5 and 10 cover. Delete the test line, or the whole file, when you are done.

Reason 12: you turned display off and expect the page to show errors

Symptom: the page shows no errors and you assume logging is broken. WP_DEBUG_DISPLAY defaults to true, and the handbook says setting it to false hides errors on the page, which is why it is meant to be used together with WP_DEBUG_LOG. With display off, the log is the only place errors appear. WordPress also forces display off for AJAX, REST, XML-RPC and JSON requests so that error text cannot corrupt a response, so a failing AJAX call never shows a notice on screen even with WP_DEBUG_DISPLAY true. Fix: read the log, not the page, and keep display off on any site other people can reach.

Reason 13: your wp-config.php change has not taken effect

Symptom: you edited wp-config.php, reloaded, and behaviour is unchanged. There are two honest explanations. The first is a cached copy of the file: OPcache checks for changed scripts every opcache.revalidate_freq seconds (default 2), and when opcache.validate_timestamps is off, which many production and managed setups do, PHP keeps serving the old file until OPcache is reset or PHP restarts, as the PHP OPcache configuration reference describes. The second is editing a copy that is not the live one: on many installs wp-config.php may also sit one folder above the WordPress root, and a staging or backup copy is easy to open by mistake.

Check: ask WordPress what it sees, not what the file says:

wp config path
wp config get WP_DEBUG_LOG

Compare the path with the file you edited. If the value is still old, clear OPcache using your host’s control panel, a PHP-FPM reload, or your host’s cache purge tool. Our OPcache settings guide for WordPress explains the validation settings. Some hosts also expose their own debug switch in the dashboard (Kinsta’s MyKinsta has a WordPress debugging tool under Tools), and a switch like that can behave differently from your own defines, so read the host’s debugging page before you assume the file is the only control.

Is my debug.log public, and how do I keep it private?

When the log works with the default WP_DEBUG_LOG = true, it lives at wp-content/debug.log, inside the web root. In our test, that URL answered HTTP 200 and served the whole log to anyone who asked. Debug logs routinely contain server paths, database table names, plugin versions, email addresses from failed mail, and sometimes request data or API keys that a plugin printed while failing. Automated scanners request /wp-content/debug.log on every WordPress site they find. Site Health will also warn “Your site is set to log errors to a potentially public file” whenever WP_DEBUG_LOG is set, even for a path outside wp-content; a core ticket from October 2025 (Trac #64071, still open when we checked) asks for a smarter test, so the warning on a private path is not proof the file is public. Request the URL yourself to know.

Best fix: keep the log outside the web root.

// wp-config.php, above the "stop editing" line
define( &#x27;WP_DEBUG&#x27;, true );
define( &#x27;WP_DEBUG_LOG&#x27;, &#x27;/var/www/private-logs/wp-errors.log&#x27; ); // folder must exist and be writable
define( &#x27;WP_DEBUG_DISPLAY&#x27;, false );

If the log must stay in wp-content, block it at the web server. On Apache, add this to the root .htaccess, outside the # BEGIN WordPress block so WordPress never rewrites it:

<Files "debug.log">
  Require all denied
</Files>

We tested this on Apache 2.4.68: the log kept being written, and the public URL changed from 200 to 403. On nginx, add location ~* /debug\.log$ { deny all; return 403; } to the server block (we did not test nginx; verify after a reload).

Then check from outside, on your real domain:

curl -s -o /dev/null -w "%{http_code}\n" https://example.com/wp-content/debug.log
# want 403 or 404, never 200

And turn it off when you are done. A debug log left on in production grows without limit, slows the site with disk writes on every notice, and keeps collecting sensitive data. Set WP_DEBUG back to false and delete the file:

wp config set WP_DEBUG false --raw
rm -f wp-content/debug.log

If you use a custom path outside the web root, the folder should not be inside public_html or htdocs and should be readable only by the PHP user and you. Rotate or delete the file after each debugging session so it never holds more than you need.

Common mistakes people report

These are the recurring causes we found in WordPress.org forum threads, Trac and host documentation, paraphrased, checked on 15 November 2026. Most of the threads are old, which tells you the same traps catch people year after year.

  • Nothing is wrong, nothing has failed yet. Replies in the forums keep pointing out that the file only appears after the first logged error, so people hunt for a bug that is not there. See Reason 11.
  • A second debug block further down wp-config.php. A resolved WordPress.org thread about a Site Health warning ended when the poster found and removed a duplicate block that overrode the first. See Reasons 1 and 2.
  • Logging to the server log without knowing it. An nginx and PHP-FPM thread from 2016 was never resolved on the forum, but the poster’s own finding was that the output was in the nginx error log. See Reasons 7 and 8.
  • Permissions guesses that do not work. A Local community thread from 2018 and a core ticket titled “Debug log never working” (opened August 2022, no confirmed cause) both show people setting 777 on a hand-made file without success. A reviewer’s first question on that ticket was whether the folder is writable by the PHP user. See Reason 4.
  • Trusting the Site Health warning as a verdict. It appears whenever WP_DEBUG_LOG is set, even for a private path, per ticket 64071. Test the URL instead.
  • Leaving debug mode on. The handbook says not to use the debug tools on live sites and to turn them off when finished. A forgotten log grows without limit and stays readable. See the public-log section.

Frequently asked questions

Why is debug.log not created even though WP_DEBUG_LOG is true?

Most often because WP_DEBUG is false (WordPress ignores WP_DEBUG_LOG without it), the defines sit below the wp-settings.php line, or PHP cannot write to wp-content. Check those three first.

Why is my fatal error missing from debug.log?

If it happens before WordPress sets up logging, for example inside wp-config.php, it goes to the web server’s error log instead. Check the server log or your host’s log viewer.

Is it safe to leave debug.log in wp-content?

Not on a public site. By default it is served to anyone at /wp-content/debug.log. Move it outside the web root with a custom path, or block it at the web server, and switch debugging off when you finish.

Does debug.log exist before the first error?

No. PHP creates it when it writes the first line, so a clean site may have no file at all. Trigger a test warning to confirm logging works.

How we tested and checked this

Scenarios 1 to 14 above ran on a disposable WordPress 7.1.3 site (PHP 8.3.35, Apache 2.4.68, Docker) on 17 October 2026, one web request per scenario, with a tagged warning so log lines from WP-CLI could not be mistaken for the test. The three host-lock cases were set in the container’s Apache and PHP configuration and reverted afterwards. The wp_debug_mode() excerpt is from that version’s wp-includes/load.php. The nginx block is the standard deny pattern and was not part of the run; test it after reloading your own server. On 15 November 2026 we re-checked the constants against the WordPress debugging handbook, the wp config set syntax against the WP-CLI documentation, and the logging logic against core trunk. Reasons 11 to 13 and the SELinux note come from documentation and public reports, not from our test run.

Stuck on an error that will not show up anywhere? Our engineers debug production WordPress sites every day, from one-off WordPress help to ongoing care plans with staging-tested updates and uptime monitoring. If an AI tool wrote the code that is failing, our AI-generated code review finds the problems before your customers do.

Part of the Wbcom Designs family

The all-in-one WordPress community stack

Also ours: wbcomdesigns.comvapvarun.combrndle.com