Most production shops, will have no logging configured. In some cases you want the Magento development logging to remain enabled.

A continuous growing log file in /data/web/public/var/log will reduce speed of your shop, so it’s important to avoid a log file that is bigger than a few MB’s.

To make sure the log files don’t grow exhaustively, we can use Logrotate, the Linux utility that rotates logfiles.

Configuring log rotate

To make use of Logrotate, first create a config file /data/web/logrotate.conf:

Now test if your config file is working:

If the returned exit code on the end of the output is 0, all is well and we’re ready to configure a cronjob that triggers Logrotate.

Running logrotate periodically

When Logrotate is working, we’ll have to make sure it is run nightly to make sure all log files are rotated frequently.

To do this add the following cron to your crontab:

Now every hour the Logrotate cronjob will verify your log files and rotate when they’re getting bigger then 50MB or when the day is over.

Additional info

Additional info can be found using the man command: man logrotate
Or in this howto with some great additional examples.

 

51