Debugging Done Right: Enabling WordPress Error Logs
Why WordPress Error Logs Are Your Website’s Best Friend
When your WordPress site breaks—whether it’s showing the dreaded white screen of death, displaying a critical error, or simply not working as expected—an error log is your roadmap to finding and fixing the problem. Enabling WordPress error logs is one of the most powerful, yet underused, ways to diagnose issues quickly and accurately.
Quick Answer: How to Enable WordPress Error Logging
- Edit
wp-config.php: Adddefine( 'WP_DEBUG', true );anddefine( 'WP_DEBUG_LOG', true );. - Find the Log File: Look for
debug.login your/wp-content/folder. - Review Errors: Check timestamps, file paths, and error messages for clues.
- Fix Issues: Use the information to identify and resolve problems with plugins, themes, or custom code.
With WordPress powering over 43% of the internet, troubleshooting errors is a critical skill for millions of site owners. Having error logs enabled can mean the difference between hours of guesswork and minutes of targeted problem-solving. Instead of wondering what broke, the log tells you exactly which file and which line caused the problem, turning frustrating detective work into a straightforward fix.
I’m Kevin Gallagher, and with over fifteen years of experience managing more than 2500 WordPress websites, I’ve seen how enabling error logs can turn a website emergency into a quick resolution. This guide will show you how to use this tool to save time, money, and stress.
What is a WordPress Error Log and Why Do You Need It?
A WordPress error log is your website’s black box recorder. It captures a detailed record of every warning, error, and potential issue that occurs behind the scenes. Without it, troubleshooting problems is like trying to fix an engine blindfolded.
Since WordPress runs on PHP, it can encounter several types of PHP errors:
- Notices: Minor issues that don’t break your site but suggest something could be improved in the code.
- Warnings: More serious problems that don’t stop the site from running but may cause incorrect behavior.
- Fatal errors: Critical issues that immediately halt your site’s execution, often resulting in a blank white screen (the “White Screen of Death”) or a generic error message.
Plugin conflicts and theme issues are common culprits. When two pieces of code don’t work well together, an error log pinpoints the source of the conflict, saving you from the tedious process of deactivating plugins one by one. Given that WordPress powers over 43% of all websites, errors are inevitable. Enabling error logs is essential for proactive problem-solving.
Understanding the Information in an Error Log
An error log entry might look technical, but it follows a simple, predictable structure:
[15-Nov-2024 14:22:33 UTC] PHP Fatal error: Call to undefined function my_custom_function() in /home/username/public_html/wp-content/themes/mytheme/functions.php on line 87
Let’s break it down:
- Timestamp:
[15-Nov-2024 14:22:33 UTC]– When the error occurred. - Error Type:
PHP Fatal error:– The severity of the issue. This one is critical. - Error Message:
Call to undefined function my_custom_function()– A description of what went wrong. - File Path:
/home/username/public_html/wp-content/themes/mytheme/functions.php– The exact file causing the error. - Line Number:
on line 87– The specific line in the file to investigate.
This information provides a direct path to the problem, turning hours of troubleshooting into a quick fix.
Common Scenarios Requiring an Error Log
Error logs are invaluable in these common situations:
- The White Screen of Death: When your site shows a blank page, a fatal error is almost always the cause. The log is the only way to see what happened.
- “Critical Error on Your Website” Message: This generic message hides the real error from your visitors. The log file contains the full, uncensored details you need for a fix. For more on this, see our guide on Fixing a WordPress Critical Error.
- Slow Website Performance: Sometimes, a flood of non-fatal warnings or notices can consume server resources and slow your site down. The log helps you find and fix these hidden performance drains.
- Post-Update Issues: If your site breaks after an update to WordPress core, a plugin, or a theme, the error log will immediately point to any new incompatibilities or bugs.
- Malfunctioning Features: When a contact form stops sending emails or a checkout process fails, the error log can reveal the underlying PHP error that is causing the feature to break.
For more troubleshooting guidance, explore our resources on WordPress Troubleshooting.
How to Manually Enable the WordPress Error Log via wp-config.php
The most reliable way to enable error logging is by editing your wp-config.php file. This core file contains your website’s base configuration, including database connection details. Because it’s so critical, you must always create a backup of wp-config.php before making any changes.
Step 1: Accessing Your wp-config.php File
You can access this file, located in the root directory of your WordPress installation, in two primary ways:
- Using an FTP Client: Connect to your server using an FTP client like FileZilla. Steer to your site’s root folder (often
public_htmlorwww), findwp-config.php, and download a backup. Then, use the client’s editor to open the file. - Using a Hosting File Manager: Log in to your hosting control panel (like cPanel) and open the File Manager. Steer to your site’s root folder, locate
wp-config.php, and use the built-in editor. Remember to download a copy first as a backup.
Step 2: Adding the Debugging Code Snippets
With wp-config.php open, scroll down until you find the line that says /* That's all, stop editing! Happy publishing. */. Just before this line, add the following code:
// 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 on screen
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Here is what each of these constants does:
| Constant | Description |
|---|---|
WP_DEBUG |
The master switch. Setting it to true turns on WordPress’s debug mode. |
WP_DEBUG_LOG |
When true, all errors are saved to a debug.log file in /wp-content/. |
WP_DEBUG_DISPLAY |
When false, errors are not displayed on the front end of your website. |
This combination is ideal for a live site: it logs errors for you to review privately without disrupting your visitors’ experience. For more details, you can refer to the Official WordPress documentation on Debugging.
Step 3: Locating and Reviewing the debug.log File
After adding the code and saving wp-config.php, trigger the error on your site again (e.g., by visiting the broken page). A new file named debug.log should now appear in your /wp-content/ directory. You can open this file with a text editor via FTP or your hosting file manager to see the recorded errors.
If the file doesn’t appear, it may be due to file permissions or because no errors have occurred since you enabled logging. Double-check your code and try to reproduce the issue to generate the log.
Introduction
What is a WordPress Error Log and Why Do You Need It?
Think of a WordPress error log as your website’s personal diary—it records what goes wrong behind the scenes so you can fix problems fast. Because WordPress runs on PHP, the log captures different PHP error types that range from harmless to site-breaking.
- Notices: Minor code issues that suggest improvements.
- Warnings: More serious problems that may cause unexpected behavior.
- Fatal errors: Critical issues that stop execution and often cause the white screen of death.
Plugin conflicts and theme issues are common sources of errors. With thousands of combinations in the ecosystem and WordPress powering over 43% of all websites, conflicts are inevitable. The log points directly to the file and line responsible, turning reactive troubleshooting into proactive maintenance.
For more resources, explore our WordPress Troubleshooting guides.
Understanding the Information in an Error Log
A typical entry looks like this:
[15-Nov-2024 14:23:45 UTC] PHP Fatal error: Call to undefined function get_custom_data() in /home/username/public_html/wp-content/themes/mytheme/functions.php on line 67
What it tells you:
- Timestamp: When the error occurred.
- Error type: Its severity (notice, warning, fatal).
- Error message: What went wrong.
- File path and line: Exactly where to look.
Common Scenarios Requiring an Error Log
- Blank pages (white screen of death): Usually caused by fatal PHP errors.
- “Critical Error” messages: The public message is generic; the log has the details. See Fixing a WordPress Critical Error.
- Slow performance: Repeated notices or warnings can waste server resources.
- Post-update breakage: After core, theme, or plugin updates, the log reveals incompatibilities.
- Broken features: Contact forms, checkouts, or custom code failing often trace to a logged PHP error.
How to Manually Enable the WordPress Error Log via wp-config.php
The most direct and reliable way to enable error logging is by editing your wp-config.php file. Always create a backup before making changes.
Step 1: Accessing and Editing Your wp-config.php File
- Via FTP: Use a client like FileZilla. Go to your WordPress root folder (commonly
public_html), download a backup ofwp-config.php, then open the server copy for editing. - Via Hosting File Manager (cPanel or similar): Open File Manager, steer to the site root, back up
wp-config.php, and edit it in place.
Note on permissions: If you cannot save, temporarily set permissions to 644, then restore to a more restrictive value such as 440 or 400 after editing.
Step 2: Adding the Debugging Code Snippets
Place the following just above the line /* That's all, stop editing! Happy publishing. */:
// 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 on screen
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Quick reference for what these constants do:
| Constant | Description |
|---|---|
WP_DEBUG |
Enables WordPress debugging mode. |
WP_DEBUG_LOG |
Writes errors to /wp-content/debug.log. |
WP_DEBUG_DISPLAY |
Hides errors from public pages on live sites. |
See the Official WordPress documentation on Debugging for more.
Step 3: Locating and Reviewing the debug.log File
After saving wp-config.php, reproduce the issue (visit the broken page). WordPress will create /wp-content/debug.log if an error occurs. Open it via FTP or your file manager to review entries. If the file does not appear, check your edits, ensure the problem was triggered, and verify file permissions.
Using a Plugin to Enable and View WordPress Error Logs
If you’re not comfortable editing your wp-config.php file, plugins offer a user-friendly way to WordPress enable error log functionality. They provide a convenient interface within your WordPress dashboard, often with added features like real-time alerts and easy-to-read log viewers.
Why Use a Plugin for Error Logging?
Using a plugin is a great option for several reasons:
- Convenience: View and manage logs directly from your WordPress admin area without needing FTP or file manager access.
- No Code Editing: Avoid the risk of making a mistake in critical files like
wp-config.php. - User-Friendly Interface: Plugins often format logs with color-coding and filters, making them easier to understand than a raw text file.
- Real-Time Alerts: Some plugins can send you an email notification when a fatal error occurs, allowing you to respond quickly.
Recommended Error Log Plugins
Several plugins can help you manage error logs. Here are two popular and reliable options:
-
Error Log Monitor: This plugin is simple and effective. It adds a dashboard widget and a tool page that displays the contents of your error log. It automatically finds the log file and uses color-coding to help you distinguish between different error types. It also includes a button to clear the log file with one click.
-
WP Debugging: This plugin offers more advanced control. It allows you to toggle
WP_DEBUG,WP_DEBUG_LOG, andWP_DEBUG_DISPLAYdirectly from the admin dashboard. It also provides additional debugging tools and can be configured to send email notifications for specific error types, making it a powerful tool for developers and site managers.
To install either plugin, go to Plugins > Add New in your WordPress dashboard, search for the plugin by name, and click “Install Now” followed by “Activate.” Once activated, you can access the error log viewer through your dashboard menu or the tools section.
How to Interpret Log Files and Fix Common Errors
Once you’ve enabled your WordPress enable error log, the next step is to understand what it’s telling you. Each error message is a clue that points directly to the source of a problem, eliminating guesswork from your troubleshooting.
For more in-depth guides on resolving specific problems, you can explore our resources on WordPress Issues.
Decoding Common WordPress Error Messages
Here are some of the most common errors you’ll find in a debug.log file and what they mean:
-
Fatal error: Allowed memory size exhausted: This means a script tried to use more memory than your server has allocated to PHP. It’s often caused by a poorly coded plugin or theme. The solution is typically to increase your PHP memory limit in your hosting settings orwp-config.phpfile. -
Parse error: syntax error: This indicates a mistake in the code’s structure, like a missing semicolon, an extra bracket, or a typo. The error message will specify the exact file and line number where the syntax error is located, making it easy to find and fix. -
Notice: Undefined index: This is a non-critical error that occurs when code tries to use a variable or array key that hasn’t been defined. While it won’t break your site, it’s a sign of sloppy code that should be fixed. -
Warning: Cannot modify header information: This error usually happens when there is whitespace, text, or HTML output before the opening<?phptag in a PHP file. The error message will tell you which file is causing the problem.
Understanding the function that caused an error can also be helpful. The PHP documentation is a great resource for looking up specific function names mentioned in error messages.
A Step-by-Step Troubleshooting Process
When you find an error in your log, follow this systematic approach:
-
Identify the Source: Look at the file path in the error message. Does it point to a plugin (
/wp-content/plugins/plugin-name/) or a theme (/wp-content/themes/theme-name/)? This tells you where to start looking. -
Isolate the Cause:
- If the error is in a plugin, deactivate that plugin and see if the error stops. If it does, you’ve found the culprit. You can then look for an alternative plugin or contact the developer for a fix.
- If the error is in a theme, temporarily switch to a default WordPress theme (like Twenty Twenty-Four). If the error disappears, the problem is with your theme. Contact the theme developer or hire a professional to fix the code.
-
Search for Solutions: Copy and paste the exact error message into a search engine. The WordPress community is vast, and it’s likely someone else has faced and solved the same issue. The official support forums and Stack Overflow are excellent resources.
-
Test After Fixing: Once you’ve applied a fix, clear your error log and test your site thoroughly. Make sure the original error is gone and that your fix hasn’t created any new problems.
This methodical process turns a confusing error log into an actionable to-do list, empowering you to resolve issues efficiently.
Security and Best Practices for Managing Error Logs
While WordPress error logging is a powerful diagnostic tool, it must be handled carefully to avoid security risks. Logs can reveal sensitive details about your server environment, file paths, and even vulnerabilities. Treat them like sensitive data.
When to Enable and Disable Error Logging
Only enable logging on a live site while you are actively troubleshooting. Then turn it off.
- Live sites: Enable temporarily to capture errors, then disable.
- Staging sites: Prefer a staging environment for ongoing debugging to avoid exposing information publicly.
To disable logging, revert values in wp-config.php:
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_LOG', false );
How to Securely Manage Your WordPress Error Log
- Prevent public access: Because
/wp-content/debug.logmay be web-accessible, block direct access via your server configuration (for Apache, use.htaccess). -
Move the log file: For stronger security, store logs in a non-public directory by adding these lines to
wp-config.php(replace the path with one outside the web root):@ini_set( 'log_errors', 'On' ); @ini_set( 'error_log', '/home/yourusername/logs/debug.log' ); // Change path to a non-public directory -
Never display errors publicly: Keep
define( 'WP_DEBUG_DISPLAY', false );on production to avoid exposing internal details to visitors or attackers.
How to Clean and Maintain Your Error Log
- Periodically delete the log file: After fixes, remove
debug.log. WordPress will recreate it when a new error occurs. - Archive if needed: Download a copy for historical records before deletion.
At wpOncall, we incorporate these practices into our support workflows, resolving issues quickly while safeguarding your site’s data and reputation.
Frequently Asked Questions about WordPress Error Logs
When you first enable WordPress error logging, a few common questions come up. Here are clear answers to help you get started.
What is the difference between WPDEBUG, WPDEBUGLOG, and WPDEBUG_DISPLAY?
These settings control how WordPress handles errors:
WP_DEBUG: Master switch that reports PHP errors, notices, and warnings.WP_DEBUG_LOG: Saves those errors to/wp-content/debug.logfor private review.WP_DEBUG_DISPLAY: Controls whether errors appear on the page. Keep thisfalseon live sites.
For troubleshooting on production, use WP_DEBUG and WP_DEBUG_LOG set to true, and WP_DEBUG_DISPLAY set to false.
Is it safe to leave WordPress error logging enabled on a live site?
Not recommended. Two risks:
- Security: Logs may expose file paths and other sensitive details an attacker could exploit.
- Performance: Debug mode adds overhead and can slow high-traffic sites.
Enable only when diagnosing an issue, then disable.
Can I delete the debug.log file?
Yes. You can delete debug.log at any time. If WP_DEBUG_LOG remains enabled, WordPress will create a new file the next time an error occurs. Deleting old logs keeps the file small and makes new issues easier to spot.
Conclusion
Mastering how to enable WordPress error logs turns you from a reactive site owner into a proactive problem-solver. Logs provide the precise information needed to diagnose issues quickly and confidently.
We covered two proven approaches:
- Manual: Edit
wp-config.phpfor maximum control and reliability. - Plugin-based: Use a dashboard-driven workflow if you prefer not to edit code.
Whatever method you choose, follow security best practices: enable logging only while troubleshooting on production, keep logs out of public reach, and never display errors to visitors.
Error logs eliminate guesswork. Instead of wrestling with a blank screen or a broken feature, you can go straight to the problem file and line number. That saves time, reduces costs, and prevents small glitches from becoming major outages.
If you would rather have experts handle it, our team at wpOncall is ready. We specialize in fast, expert WordPress support—daily updates, backups, and unlimited issue resolution—so your site stays healthy and secure. Explore our WordPress Support Services or get ongoing care with WordPress maintenance and support.