}
Magento is a powerful and, at the same time, complex Ecommerce solution.
Logging is one of it's important functions.
As any other application, after operating for some time, Magento's performance may suffer because of the more and more events data it collects.
In this article, we'll show you how to setup Log Cleaning as well as manually clean the database to avoid performance issues.
Magento uses two types of logs data collecting.
These contain notifications, warnings and errors related to Magento's code.
System >> Configuration >> Advanced >> Developer >> Log settings:
These are saved to the local filesystem in var/log/ and are disabled by default.
These logs needs to be checked and cleaned periodically, as they can get huge in size.
The best method to do that would be via a cron job which you can setup in your cPanel.
Example command line:
1) If you want to keep a copy of the logs:
zip -9 /magento-install-dir/var/log/system-exception.log-`date +%d-%m-%Y-%H-%M`.zip /magento-install-dir/var/log/system.log /magento-install-dir/var/log/exception.log
Replace magento-install-dir with the actual path to your Magento installation directory.
I can recommend running the above on the 1st and 15th of each month:
Compressing the logs can save you more than 90% of the file size!
2) If you do not need a copy of the logs, you can create a cron job with the following command:
> /magento-install-dir/var/log/system.log && > /magento-install-dir/var/log/exception.log
Replace magento-install-dir with the actual path to your Magento installation directory.
If you actually do not need a copy, then consider disabling this kind of logging.
log_customer – information about customer login/logout time and date
log_visitor – information about visitor session
log_visitor_info – visitor locale preferences
log_visitor_online – date and time of the first and the last visit, the last visited URL
log_summary – visitors summary report by a date
log_summary_type – summary types and descriptions
log_url – visited URLs for each visitor
log_url_info – information about visited URLs
log_quote – contains quotes history by visitors
index_event – events that occurred in Magento for products, catalogs. Editing or deleting etc
report_event – history of some visitors/customers actions in store
report_viewed_product_index – history of viewed products by visitors/customers
report_compared_product_index – history of compared products by visitors/customers
catalog_compare_item – compared products according to customer
dataflow_batch_export – history of batches exports
dataflow_batch_import – history of batches imports
There are 2 ways cleaning the above.
1) Using Magento Log Cleaning:
You can enable it from your Magento admin panel >> System >> Configuration >> Advanced section >> System >> Log:
Configure the value for the Save Log, Days where the recommended value is 15.
Then set Enable Log Cleaning to Yes and save the changes.
The automated log cleaning procedure is executed via the Magento cron job, so make sure that it is configured to work properly.
2) Clean the logs via SSH.
Login to your account via SSH and navigate to the Magento installation directory.
We will be using the shell/log.php tool, so you can first check it's help page by running:
php -f shell/log.php help
Then, you can check the logs statistics using:
php -f shell/log.php status
and finally, clean the logs using:
php -f shell/log.php clean
If you do not have SSH access enabled - let us know and we'll enable it for you free of charge.
That's how you clean Magento logs and keep it in a good shape. Should you need any further assistance, please do not hesitate to contact us.
Powered by WHMCompleteSolution