A bulky Magento database can always pull down the performance of your websites.

Therefore, server owners sometimes disable visitor log in Magento to improve the database performance.

At Bobcares, we help website owners optimize their Magento website applications as part of our Dedicated Support Services.

Today, let’s see how our Support Experts disable visitor log in Magento.

Disable visitor log in Magento – Why it’s needed?

Magento, by default, has an extensive logging system. In other words, it logs all the user activity information to the database. This is useful, because it helps website owners analyze the behavior and activities of their customers.

Magento has a Mage_Log module that stores the log data of visitors. It mainly stores information such as current visitors, visitor IP address, first visit, last visit, etc. However, Magento database size eventually grows, which in turn causes disk space issues and reduces the overall performance of the website.

In such cases, we need to disable logging in Magento. However, this has many disadvantages. One such major problem is that the product comparing doesn’t work correctly if we disable visitor log.

So, our Support Engineers recommend customers to disable visitor log in Magento if they use any external services such as Google Analytics. Customers usually disable visitor logging from System > Configuration > Advanced > System > Log > Enable Log in Magento admin panel.

magento disable visitor log

How to disable Logging in Magento?

 

However, we’ve seen instances where this doesn’t become successful and Magento still writes information to the log tables.

Disable visitor log in Magento – How to do it?

Now, let’s see the different methods used by our Support Engineers to disable visitor log in Magento.

1) Disable logging in Local configuration file

Our Support Engineers disable the visitor log by adding the following code before </config> in the configuration file app/etc/local.xml.

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

 

Further, we make sure to disable Mage_log module from System > Configuration > Advanced and flush the Magento cache from System > Cache Management in Magento admin panel.

Then, Magento will no longer write logs to the tables. To clear the existing log information, our Support Experts manually truncate the log tables. For example, we truncate the log_customer and log_visitor tables using the below command.

TRUNCATE log_customer;
TRUNCATE log_visitor;

 

Alternatively, we clear these log tables from phpMyAdmin control panel also. But, note that once we truncate the tables, all the log data will be permanently lost. So, we always confirm with the customers before clearing these tables.

2) Magento Extensions

Likewise, we can disable visitor log using Magento extensions as well. Our Support Experts ask customers to use Magento extensions such as DisableLog. We disable the logs for all the requests being made or for search bots.

For shops with bulky databases, this can reduce the update/insert queries thereby improving load times of the website.

For example, to completely disable logging using DisableLog extension, we set the parameter Disable All Logs to Yes. This disables the logs for users requests and search bots.

3) Modify the Core model

Similarly, another method to disable visitor log in Magento is to edit the Mage_Log core model. Our Support Engineers add/modify the below line as follows in the file /app/code/local/Mage/Log/Model/Visitor.php.

protected $_skipRequestLogging = true;

Most importantly, we backup this file before making any changes. Also, modifying the modules in Magento is not recommended.

4) Enable log rotation

Customers can also clear the Magento logs manually using the shell utility log.php. This will take some time depending on the size of the logs.

php -f shell/log.php clean

 

However, this requires shell access(SSH access) for the customer. That’s why our Support Engineers suggest the option of automatic Magento log cleaning. This leaves the log data in place, but the database won’t become too large with the log entries. We enable automatic log cleaning using the below steps.

  • Go to System > Configuration > Advanced > System > Log cleaning.
  • Change Enable Log Cleaning to Yes.
  • Set Save Log field to small values such as 1 or  2 days.
  • Click Save Config.

 

magento disable visitor log

How to enable Log rotation in Magento?

 

The automatic log clearing will happen through a Magento cron job. So, our Magento Experts ensure that proper cron jobs are in place to do this process.

[Need an expert to resolve the performance issues of your Magento website? Our Magento Experts can help you here.]

Conclusion

In short, customers disable visitor logs in Magento to improve the website performance. Today, we’ve discussed the top 4 methods used by our Dedicated Support Engineers to disable database logging in Magento.



Source link

Author

Write A Comment