filled up error log wordpress

How to Stop Your WordPress Error Log from Filling Up

If your WordPress error log is growing rapidly and taking up valuable server space—sometimes reaching 20GB or more—you need to take action. A massive error log not only slows down your website but can also indicate serious underlying issues. Sometimes, your emails will stop working if this happens due to your allocated server space being used up. In this guide, we’ll walk you through how to stop your WordPress error log from filling up and fix the root cause of the problem.

filled up error log wordpress

1. Check the Error Log for the Root Cause

Before making changes, it’s essential to check what’s causing the errors in the first place.

  • If you have access to your hosting control panel (like cPanel or Plesk), navigate to:
    • public_html/error_log
    • wp-content/debug.log
  • If using SSH, you can view the last 100 lines of the log file with:
    tail -n 100 error_log
  • Identify recurring errors, which could be due to:
    • Plugin conflicts
    • Theme issues
    • PHP errors
    • Outdated WordPress or plugins

Fixing these errors is crucial for long-term stability.

2. Disable Debug Logging (If Enabled)

If WordPress debugging is turned on, it continuously logs errors, which can quickly fill up your server storage.

To disable it:

  1. Edit your wp-config.php file.
  2. Look for these lines:
    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);
  3. Change them to:
    define('WP_DEBUG', false);
    define('WP_DEBUG_LOG', false);
    define('WP_DEBUG_DISPLAY', false);
  4. Save and upload the file back to your server.

This will stop WordPress from continuously writing to the error log.

3. Limit Log File Size

If your server allows, you can limit the size of the log file by adding the following to your .htaccess file:

php_value log_errors_max_len 1024

This ensures that the log doesn’t grow uncontrollably.

4. Delete the Log File & Prevent Overgrowth

You can manually delete the error_log file via FTP, cPanel, or SSH:

rm error_log

To prevent it from growing excessively, you can set up an automatic log rotation on a Linux server by adding this to your crontab:

0 0 * * * truncate -s 0 /path/to/error_log

This will reset the log file daily at midnight.

5. Fix the Underlying Errors

Simply disabling logging isn’t a true fix—you need to resolve the underlying issues.

  • Check Plugins: Deactivate all plugins and reactivate them one by one to find the problem.
  • Switch Themes: Try a default WordPress theme (like Twenty Twenty-Four) to rule out theme-related errors.
  • Update Everything: Ensure your WordPress core, plugins, and themes are up to date.
  • Check PHP Version: Use PHP 8.0+ for better compatibility and security.

6. Use a Plugin for Log Management

If you want an easier way to manage error logs, consider using a plugin:

  • WP-Optimize – Helps clean up log files and optimize database performance.
  • WP Log Cleaner – Allows you to delete and manage logs with ease.

7. Contact Your Hosting Provider

If the issue persists, your hosting provider might help by:

  • Identifying server-level issues
  • Adjusting log settings
  • Upgrading your hosting plan if needed

Final Thoughts

A bloated error log can slow down your site and indicate deeper issues that need fixing. By checking your logs, disabling unnecessary debugging, limiting log file size, and fixing errors at the source, you can keep your WordPress site running smoothly.

If you found this guide helpful, share it with other WordPress users facing the same problem!