The Perfect Logrotate Config

December 6, 2011

One of the first things I do when setting up a new server somewhere is get all those damn log files rotating. Here’s the logrotate.conf block I use:

`</p>

in /etc/logrotate.conf

/path/to/any/log/file/*.log {
daily
dateext
missingok
rotate 365
compress
delaycompress
notifempty
copytruncate
}

` This is a slight modification of [this configuration][1]. Check out his explanation for all of the params. The one I added that I think is essential is `dateext`, which appends dates instead of incrementing digits to the end of the log files, like so: `
-rw-r--r-- 1 britg britg 64M 2011-10-24 06:49 production.log-20111024.gz
-rw-r--r-- 1 britg britg 62M 2011-10-25 06:52 production.log-20111025.gz
-rw-r--r-- 1 britg britg 56M 2011-10-26 06:29 production.log-20111026.gz
-rw-r--r-- 1 britg britg 56M 2011-10-27 06:51 production.log-20111027.gz
-rw-r--r-- 1 britg britg 57M 2011-10-28 06:51 production.log-20111028.gz
` Which, in my opinion, is much more parseable by our puny human brains. [1]: http://www.nullislove.com/2007/09/10/rotating-rails-log-files/