How to Enable and View Error Logs in WordPress

When developing or troubleshooting a WordPress website, encountering issues is inevitable. To diagnose and resolve problems effectively, it’s crucial to access error logs that provide behind-the-scenes information on what’s going wrong. WordPress, being a PHP-based content management system, allows users to enable error logging either through its core configuration or via server settings. This guide will explain how to enable and view error logs in WordPress, offering a detailed step-by-step process that even non-developers can follow.

Contents

Why Enable Error Logs in WordPress?

Debugging errors without logs is like searching for a needle in a haystack. WordPress error logs make the troubleshooting process clearer and more manageable. Here are a few reasons why enabling logging is beneficial:

  • Identifying plugin or theme conflicts
  • Monitoring deprecated functions and outdated code
  • Diagnosing white screen errors (WSOD)
  • Receiving warnings about PHP performance issues

Once enabled, WordPress error logs offer insight into everything from minor warnings to critical system failures.

What You Need to Get Started

Before you begin, make sure you have:

  • Access to your WordPress installation files via FTP or your hosting file manager
  • A basic understanding of PHP or confidence in editing configuration files
  • A text editor like Notepad, VS Code, or any code editing tool

With these in hand, you’re ready to proceed.

Step 1: Enable Debugging in wp-config.php

The wp-config.php file is the core configuration file for your WordPress site. To enable error logging, follow these steps:

  1. Navigate to the root directory of your WordPress installation (usually called public_html or www).
  2. Locate the wp-config.php file and open it in a text editor.
  3. Find the line that says /* That's all, stop editing! Happy publishing. */.
  4. Just above this line, insert the following code:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Explanation of each line:

  • WP_DEBUG: Enables WordPress debugging mode.
  • WP_DEBUG_LOG: Logs errors to the debug.log file located in the /wp-content/ directory.
  • WP_DEBUG_DISPLAY: Prevents error messages from displaying publicly on the front end.

Step 2: Locate and View Error Logs

After enabling debugging, WordPress will automatically begin logging errors to a file named debug.log inside the wp-content directory. Here’s how to view it:

  1. Using FTP or your file manager, navigate to the wp-content folder.
  2. Look for a file named debug.log.
  3. Download or open this file in a text editor.

You’ll find entries including timestamps, file paths, error types, and specific messages that identify what went wrong.

If the file is not there: It may mean no errors have occurred since debugging was enabled or your server isn’t configured to allow writing to that location. Check file permissions or consult your host if necessary.

Step 3: Adjust PHP Configuration for Extended Logging

Sometimes, WordPress logs may not capture all PHP-level errors, especially if server configurations override WordPress settings. To ensure full error logging, you can adjust the php.ini or .htaccess file.

Option 1: Modify php.ini

Locate the php.ini file and add the following directives:


log_errors = On
error_log = /full/path/to/your/logs/php-error.log

This step defines a global PHP error log location, often useful on VPS or dedicated hosting.

Option 2: Use .htaccess File

If you cannot access php.ini, you can modify the .htaccess file in the root directory:


php_flag log_errors on
php_value error_log /full/path/to/your/logs/php-error.log

Note: If you’re unsure of the server path, you can create a test PHP file with phpinfo() to determine it.

Step 4: Enable Logging through a Plugin (Optional)

For less technical users, using a plugin is a simpler alternative. Some widely used plugins include:

  • Query Monitor: Provides debugging messages, PHP errors, and database query information.
  • WP Log Viewer: Allows admins to view the debug.log directly from the dashboard.

To install one of these:

  1. Navigate to Plugins > Add New in the WordPress dashboard.
  2. Search for “Query Monitor” or “WP Log Viewer.”
  3. Click Install and then Activate.

This method is ideal for those who prefer not to interact with raw configuration files.

Step 5: Disable Debugging When Not Needed

Running a live site with debugging enabled can expose sensitive data. Always remember to turn it off once you’re done troubleshooting. To disable error logs:


define( 'WP_DEBUG', false );
define( 'WP_DEBUG_LOG', false );
define( 'WP_DEBUG_DISPLAY', false );

Save and upload the changes to wp-config.php. This will stop logging and help optimize your site’s performance.

Bonus Tips for Managing Error Logs

  • Automate log management: Use cron jobs or plugins to archive or delete old logs.
  • Use log monitoring tools: Third-party services like Loggly or Papertrail can centralize WordPress logs for better tracking.
  • Notify team members: Implement email alerts or Slack integrations for critical errors.

Conclusion

Enabling and viewing error logs in WordPress is a straightforward process that can significantly enhance your ability to maintain a stable website. Whether you’re a developer handling complex customizations or a site owner experiencing white screen issues, error logs provide unmatched visibility into WordPress diagnostics.

By following these steps—editing the wp-config.php file, checking the debug.log, modifying PHP configs, or even installing plugins—you’ll be better equipped to troubleshoot and solve issues before they impact user experience.


Frequently Asked Questions (FAQ)

What is the default location of the WordPress error log?
The default location is /wp-content/debug.log if logging is enabled via wp-config.php.
Will enabling WP_DEBUG slow down my site?
Yes, leaving debugging on in production can slightly affect performance and may display errors publicly if not configured properly. Always disable it when not in use.
Can I view logs directly from the WordPress dashboard?
Yes, using plugins like “WP Log Viewer” or “Query Monitor” allows you to view error logs from the admin panel without accessing the file system.
What if my debug.log file is empty?
This could mean there are no recent errors, or that your server isn’t configured to allow WordPress to write to that file.
Is it safe to share error log files?
No. Logs may contain sensitive information such as file paths, database queries, and even user data. Always sanitize logs before sharing