14 Oct WordPress Error Log: WP_DEBUG_LOG vs PHP Error Logs for Troubleshooting Website Errors
Use WP_DEBUG_LOG first when a WordPress-specific error appears, then check the PHP error log when the issue looks server-level, intermittent, or fatal before WordPress fully loads. That order saves time because WordPress powers a huge share of sites, about 43% of all websites tracked by W3Techs, so many errors start inside themes, plugins, hooks, and updates [source: W3Techs]. Still, PHP logs often catch the ugly stuff WordPress never gets the chance to record.
TLDR: WP_DEBUG_LOG is best for plugin, theme, shortcode, REST API, and WooCommerce errors because it records WordPress warnings and notices in context. PHP error logs are better for server crashes, memory failures, permissions issues, and fatal errors that happen before WordPress loads. For example, if a checkout page fails after a plugin update, wp-content/debug.log may show the exact plugin file and line number in under a minute, while the PHP log may show a 256 MB memory limit exhausted error. In a small support workflow, checking both logs can cut troubleshooting from 30 minutes to 10 minutes because you stop guessing.
What WP_DEBUG_LOG Actually Does
WP_DEBUG_LOG is a WordPress debugging setting. When enabled, it writes WordPress-related PHP errors, warnings, notices, and deprecated function messages to a log file. By default, that file is usually:
wp-content/debug.log
To enable it, you add or edit these lines in wp-config.php:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
This setup logs errors without showing them to visitors. That matters. Nobody wants a customer seeing raw PHP warnings on a checkout page. It looks broken because, well, it is.
WordPress also allows a custom log path in newer versions, which is useful if you do not want debug.log sitting inside a public content folder. The official debugging guide explains the main constants and their roles [source: WordPress].
What PHP Error Logs Do Differently
PHP error logs are not WordPress-specific. They are produced by PHP itself, often through configuration in php.ini, the web server, your hosting control panel, or container logs if the site runs in Docker or cloud hosting.
A PHP error log may live in different places, such as:
/var/log/php/error.log/var/log/apache2/error.log/var/log/nginx/error.log- A hosting panel section called Errors, Logs, or Diagnostics
- A path set by
error_loginphp.ini
This log sees errors outside the WordPress bubble. That includes failed PHP extensions, permission blocks, file ownership problems, memory exhaustion, process crashes, and syntax errors in loaded PHP files.
Honestly, it feels like hosting panels hide these logs for sport. On one host they are under Metrics. On another they sit inside a raw file manager folder. Expect to waste a few extra minutes finding the real log path the first time.
WP_DEBUG_LOG vs PHP Error Logs: The Practical Difference
Think of WP_DEBUG_LOG as the WordPress conversation. Think of the PHP error log as the server’s complaint box.
| Situation | Best Log to Check First |
|---|---|
| Plugin update causes warnings | WP_DEBUG_LOG |
| Theme template throws errors | WP_DEBUG_LOG |
| White screen of death | PHP error log, then WP_DEBUG_LOG |
| Memory exhausted error | PHP error log |
| 500 Internal Server Error | PHP error log |
| Deprecated WordPress function warning | WP_DEBUG_LOG |
| Scheduled task failure | Both |
WP_DEBUG_LOG gives cleaner context for WordPress behavior. It may show the plugin folder, the function name, and the line number. PHP logs may show the same fatal error, but with less WordPress context.
PHP logs win when WordPress cannot load far enough to write anything. If a syntax error breaks wp-config.php, WordPress logging may never start. The server log will usually still catch it.
Common Error Messages and What They Mean
Some errors look scary but are easy to sort once you know where to look.
- PHP Fatal error: The script stopped. Check the file path and line number first.
- Allowed memory size exhausted: A plugin, theme, import job, or query used too much memory.
- Call to undefined function: A plugin expects code that is missing, disabled, or loaded too late.
- Cannot modify header information: Output was sent before headers. Often caused by whitespace, debug output, or a plugin warning.
- Deprecated: Code still works, but it relies on old PHP or WordPress behavior.
- Permission denied: The server cannot read, write, or execute a file it needs.
The useful part is rarely the first word. The useful part is the file path, line number, and timestamp. Match the timestamp to the moment you clicked the broken page. If the error appears at 14:03:11 and your test failed at 14:03, you probably found the right clue.
When to Use Both Logs Together
Use both logs when the issue is messy. That includes checkout failures, admin crashes, cron problems, REST API errors, import timeouts, and random 500 errors.
A good sequence looks like this:
- Reproduce the bug once. Do not click twenty times and flood the log.
- Check
wp-content/debug.logfor WordPress-specific messages. - Check the PHP error log for fatal errors and memory issues.
- Compare timestamps.
- Disable or roll back the named plugin, theme, or custom snippet.
- Test again and confirm the log stops growing.
This is where logs become better than guessing. If the log says /plugins/example-plugin/includes/api.php on line 82, do not start by changing the theme. Start with that plugin. It sounds obvious, but panic makes people click everything.
Security Mistakes to Avoid
debug.log can expose paths, plugin names, usernames, API URLs, and other details. Never leave it exposed on a live site longer than needed.
After testing, switch debugging off:
define( 'WP_DEBUG', false );
Also consider deleting old log files. If you keep logging active for staging, place the log outside the public web root when possible. At minimum, block public access to debug.log through server rules.
Best Workflow for Real Troubleshooting
Start with the symptom. If the WordPress admin works and only one plugin feature breaks, open WP_DEBUG_LOG. If the whole site returns a blank page, status 500, or a server timeout, open the PHP error log first.
Use staging when possible. Trigger the same action there. Update one plugin at a time. Change one setting at a time. Then check the newest log entry. Small steps beat heroic guessing.
The simple rule: WP_DEBUG_LOG tells you what WordPress noticed. PHP error logs tell you what the server could not ignore. For fast troubleshooting, read both, match the timestamps, and fix the file named in the error before touching anything else.
Sorry, the comment form is closed at this time.