Select Page

Magento Basics – How To Clear Magento Log Files

by | Mar 22, 2015 | Magento Advice | 0 comments

Over time Magento log files build up causing your database to increase in size. This can cause issues in your site speed & can cause backup issues.

A common question that my clients ask is, how to clear Magento log files.

How To Clear Magento Log Files

There are 2 methods to clear your Magento log files:

Method 1

In later versions of Magento the log files can be cleaned periodically with a Cron job. Firstly this has to be configured in your Magento backend.

System -> Configuration -> Advanced -> System -> Log Cleaning

Magento Log Cleaner

Magento Log Cleaner

The configuration of this is pretty straight forward.

Save Log, Days: This field sets the amount of days that your logs are stored for. I recommend 60 days.

Enable Log Cleaning: Set to yes to enable the Cron.

Start Time: This is the time that your logs will be cleared. I recommend setting this to a low traffic period as website performance may be effected slightly whilst the Cron is running.

Frequency: This is how often the Cron will check for logs that are over 60 days old.

Error Email Recipient: You should ensure this is set so you are informed of any errors or issue with the script.

Error Email Sender: This can be left as default.

Error Email Template: This can be left as default.

Method 2

This method is slightly more advanced than the previous method and should only be used if you are comfortable with MySQL.

Using PHPMyAdmin run the following query on your Magento database.


TRUNCATE dataflow_batch_export;
TRUNCATE dataflow_batch_import;
TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
TRUNCATE log_visitor_online;
TRUNCATE report_viewed_product_index;
TRUNCATE report_compared_product_index;
TRUNCATE report_event;
TRUNCATE index_event;

This will clean all the log files that are not needed for your Magento store to function.

Conor Tomkins

Conor Tomkins

Senior PHP Developer

Working with PHP applications since the age of 17. I have a wide range of knowledge on most PHP open source platforms. I must admit, my favorites are Magento & Wordpress!

Still need answers?