Disable Magento logging to the database
Posted on: January 8, 2015

Magento has 2 types of logging: errors of magento and user actions. When logging is enabled magento performance decreases.

Logging errors by default is disabled. It should be turned on only during the development of the site. All information about errors Magento writes to a file: [magento root] > var > log > system.log. Activate it here System > Configuration > Advanced > Developer > Log Settings.

Information about logging user actions stored in the database. Their cleaning takes place according to the schedule, the default 30 days. But if magento not set cronjob, then cleaning will be not runned and the database will only increase, and the site will work slower. Disabling of admin module Mage_Log not bring results. See a method below that allows you to disable logging in magento.

Be careful! The product comparing does not work correctly if you disable the visitor log.

1. Open your app/etc/local.xml file
2. Paste in the following, right before the closing tag:

<frontend>
    <events>
        <controller_action_predispatch>
            <observers><log><type>disabled</type></log></observers>
        </controller_action_predispatch>
        <controller_action_postdispatch>
            <observers><log><type>disabled</type></log></observers>
        </controller_action_postdispatch>
        <customer_login>
            <observers><log><type>disabled</type></log></observers>
        </customer_login>
        <customer_logout>
            <observers><log><type>disabled</type></log></observers>
        </customer_logout>
        <sales_quote_save_after>
            <observers><log><type>disabled</type></log></observers>
        </sales_quote_save_after>
        <checkout_quote_destroy>
            <observers><log><type>disabled</type></log></observers>
        </checkout_quote_destroy>
    </events>
</frontend>

3. Save your local.xml file
4. Go to System > Configuration > Advanced and set Mage_Log to Disable
5. Finally, flush your Magento caches under System > Cache Management

Magento should no longer write logs to these tables.

To clear existing tables, perform queries:

WARNING: the log information will be permanently lost!

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_event;

Leave a Reply

Your email address will not be published. Required fields are marked *