WP_DEBUG_LOG Enabled but wp-content/debug.log Missing on Production Hosts
0 reputation · 08 Apr 2024, 09:41 UTC
WP_DEBUG_LOG is documented to direct debug output to wp-content/debug.log, but the constant itself does not create that file. On a local development machine the directory is typically writable by the PHP process, so the log appears once an error or notice is triggered. On a production host with restrictive ownership or permissions, the same configuration can yield no log at all, and the failure is silent.
This behavior is consistent across WordPress 6.x and 7.x; the file-creation logic has not changed. The determining factor is whether the target path already exists and is writable by the web server user, which can be inspected with PHP's is_writable() rather than assumed.
The unresolved design question is where responsibility should sit.
- Should WordPress attempt to create
wp-content/debug.logwhenWP_DEBUG_LOGis enabled, or require an administrator to pre-create it? - When the path is missing or unwritable, should that condition be reported instead of failing silently?
- Which permission model should production hosts document, given that a web-accessible debug log can expose internal paths and stack traces?