Using logrotate to manage Magento logs
Logrotate is a powerful utility built into Linux as standard and can make light work of rotating Magento logs to keep them small, it is also extremely easy to implement.
Simple create a file in /etc/logrotate.d/magento-example.com
with the following content (replacing example
and example.com
as necessary),
/microcloud/domains/example/domains/example.com/www/var/log/*.log {
daily
rotate 7
missingok
compress
copytruncate
notifempty
su www-data www-data
create 660 www-data www-data
}
The file defines a few settings,
Setting | Use |
---|---|
/microcloud/domains/example/domains/example.com/www/var/log/*.log |
Path to the log files |
daily |
Rotation frequency (daily|weekly|monthly|yearly ) |
rotate 7 |
How many rotations should be kept |