Excessive Logging – Part 2: Magento

magento

A very reliable tool to build e-shops is Magento. It is a powerfull tool when it comes to shop owners, but it can be a pain in the ass to set it up and when it comes to problem solving, the error reporting system is horrific!

It seems that if you install Magento from the autoinstaller, the system keeps the visitors log in the database. It also seems that the database builds up pretty quick.

So I made a small php script that truncates (empties) the visitors log keeping the database in a reasonable size. Combined with a cron job it truncates the database every 15 days.

<?php
$mysqli = new mysqli(“host”, “user”, “password”, “database”);
if ($mysqli->connect_errno) {
echo “Failed to connect to MySQL: (” . $mysqli->connect_errno . “) ” . $mysqli->connect_error;
}
$mysqli->query(“TRUNCATE TABLE log_url”);
$mysqli->query(“TRUNCATE TABLE log_url_info”);
$mysqli->query(“TRUNCATE TABLE log_visitor”);
$mysqli->query(“TRUNCATE TABLE log_visitor_info”);
?>

Nothing special, but gets the job done.

To set up a cron job use the instructions here: http://www.timlinden.com/blog/website-development/php-cron-jobs-with-cpanel/