MAGENTO: Clean Exeption.log and System.log

MAGENTO: Clean Exeption.log and System.log

September 15, 2026 · Illustrated author avatarBy Stefan Bogdanescu
MAGENTO: Clean Exeption.log and System.log

Magento Log Cleanup: Handling Exception.log and System.log

As your Magento store grows, you may notice that the Exception.log and System.log files located under /var/log can quickly balloon to several gigabytes in size. While it might seem tempting to simply delete these logs to free up space, let’s explore a more responsible approach.

Understanding Magento Log Files

Before we discuss cleanup methods, it’s important to understand the purpose of each log file:

  • Exception.log: This file records all uncaught exceptions that occur during your store’s operation. It provides valuable insights into runtime errors and is crucial for debugging.

  • System.log: This log captures general system activities, including information messages, warnings, and notices emitted by Magento core files and extensions. While less critical than exceptions, it still contains important operational data.

The Dangers of Manual Deletion

Deleting these logs manually through the file manager or via command line can have serious consequences:

  1. Data Loss: You’ll erase all historical records of errors and system events that occurred prior to deletion. This could include vital information needed for future troubleshooting.

  2. Performance Issues: Magento uses log files as a primary channel for debugging. Deleting them may cause unexpected behavior or performance degradation, especially with third-party extensions.

A Safe Approach: Log Rotation

Instead of outright deletion, the recommended practice is to rotate logs using a systematic approach:

1. Enable Log Rotation in PHP.ini

Open your php.ini file (usually found in the public directory) and ensure that the following settings are enabled for log rotation:

log_errors = On
error_log = /var/log/magento Exception.log

This tells PHP to write all error logs to the specified file, which will be automatically rotated by Magento.

2. Configure Log Retention

By default, Magento retains only the last 30 days of logs. To adjust this:

  • Navigate to Stores > Configuration > Advanced > Developer.
  • Set “Log Retention Period” to a value that suits your needs (e.g., 90 days).
  • Click “Save Config”.

3. Clear Old Log Files

To delete only the oldest log files that have exceeded the retention period:

  1. SSH into your server.
  2. Navigate to /var/log.
  3. Run the following command:
find . -name "*.log" -mtime +90 -exec rm {} +

This command finds all log files older than 90 days and deletes them.

Conclusion: Responsible Log Management

While it’s understandable to want to clear up disk space, deleting Magento logs without proper rotation can lead to data loss and operational issues. Always follow the official Magento guidelines for log management:

  • Regularly monitor your log files for any errors or warnings.
  • Use the built-in log retention settings to control storage size.
  • Never delete Exception.log manually—always use the system’s automatic rotation features.

Remember, logging is a critical component of a healthy e-commerce environment. With responsible management and periodic cleanup using log rotation, you can maintain optimal performance without compromising your store’s stability or diagnostic capabilities.

For more advanced insights into Magento maintenance best practices, be sure to explore our comprehensive guides at Laravel Company.

Performance Extensions Themes Import/Export

Our network