Rotating Application Logs

Nobody likes 2 Gig Rails log files. Put this into /etc/logrotate.d/mongrel :


"/var/www/apps/*/shared/log/mongrel*log" "/var/www/apps/*/shared/log/production*log" {
    daily
    rotate 7
    compress
    missingok
    sharedscripts
    postrotate
      /etc/init.d/mongrel_cluster restart
    endscript
}

Make sure logrotate is installed: yum install logrotate

This says your logs will be kept for 7 days, compressed, and that your mongrel_cluster will be restarted afterwards. Check the man page for more options.

Meta