[Mongrel] Rotating mongrel production logs

Sean Brown seanmichaelbrown at gmail.com
Thu Feb 14 12:29:54 EST 2008

In another thread, I had posted that we rotate our mongrel production
logs once a week as a means to keep the performance degradations that
happen with large log files at bay.  A few of you asked me to post how
we do it, so here it is.  We run our sites on RedHat Enterprise 4
machines.  Our logrotate.conf file looks like this:

# see "man logrotate" for details
# rotate log files weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones

# uncomment this if you want your log files compressed

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
    create 0664 root utmp
    rotate 1

# system-specific logs may be also be configured here.

# mongrel logs
/path/to/rails/root/shared/log/*.log {
        olddir /path/to/rails/root/old_mongrel_logs
        rotate 28
          for i in `ls /path/to/rails/root/shared/log/mongrel*.pid`; do
            kill -USR2 `cat $i`

Incidentally, we also use monit to monitor our various processes
(mongrel, Apache, ferretDRb MySQL, etc), so if for some odd reason
this log rotation would not bring one of our mongrels back up cleanly,
we'd be alerted and monit would try to restart it.  So far, this has
not happened at all across any of our 6 production setups just like

None of the sites are extremely high traffic, so it's possible that
you'd want to rotate mongrel log files more frequently than weekly.

I hope this helps.


Sean Brown
seanmichaelbrown at gmail.com

More information about the Mongrel-users mailing list