Magento log cleaning

in Magento Tags: databaseMagentoperformance

Magento log cleaning helps you keeping your Magento shop fast by cleaning and optimizing your database(s).

What is Magento log cleaning?

Magento saves your web statistics by logging these in your database. This data is useful, but it takes up a lot of disk space and unfortunately Magento’s database is not very efficient. To keep your Magento shop optimized and thus fast, you’ll need to clean these logs. An easy way of cleaning up your database is by enabling Log Cleaning in the backend of Magento. This method is called ‘Automatic log cleaning’. More advanced Magento users can manually clean their logs. 

Automatic log cleaning

Magento offers an easy tool to clean your logs. When you’re not familiar with Magento’s database system, we recommend you to use this tool. Simply follow the steps written below:

  1. Log into your Magento backend System -> Configurations;
  2. In the left menu under Advanced click on System;
  3. Under Log Cleaning, change Enable Log Cleaning to YES and configure the Save Log for 7 days You can change the number of days you wish to keep the logs, see screenshot below.
  4. Click Safe Config.
Magento log cleaning backend

1. Automatic Magento log cleaning

The most important setting is Save log for .. days. We recommend you to pick a number between 1 and 30 days.

How to clean your logs manually

Cleaning your Magento logs manually is the most effective way of cleaning your logs. Cleaning logs manually is not recommended if you’re not familiar with databases. You can use SSH or PHPMyAdmin to clean up.

Manual log cleaning with SSH

Log on to your SSH server, navigate to the root of your Magento shop and use the following command:

php -f shell/log.php clean

Manual log cleaning with PHPMyAdmin

Open your database in PHPMyAdmin and select the following tables:

  • dataflow_batch_export
  • dataflow_batch_import
  • log_customer
  • log_quote
  • log_summary
  • log_summary_type
  • log_url
  • log_url_info
  • log_visitor
  • log_visitor_info
  • log_visitor_online
  • report_viewed_product_index
  • report_compared_product_index
  • report_event

Scroll down to select ‘Empty’ from the dropdown ‘With selected’ and click yes.

Turn off database logging

If you don’t need any database logging it can be worthwhile to disable all logging. To do so, install the disablelog extension by Yireo.
For shops that are heavy on the database, this can help reduce the amount of update/insert queries and therefore reducing load times.

0