Rails log rotations via rsyslog December 25, 2008
Posted by John Dewey in Code, Configuration, Deployment, Example, Rails.trackback
I have a client that logs their rails logs via syslog, for consumption by pl_analyze. I am not a fan of this, and will probably change it at some point. When using Apache, I’ll typically configure rails to use a rotatelogs pipe.
However, in this case, to avoid changing legacy infrastructure around the logs, I setup rsyslog to do the rotations for me. Hopefully this will be useful to someone else.
This assumes your rails app already logs to syslog.
Added the following to /etc/rsyslog.conf.
you can also use a pure-rails solution if you do not want to interact with other applications
e.g. config.logger = Logger.new(config.log_path, 3, 10 * 1024**2)
http://pragmatig.wordpress.com/2009/03/03/logfiles-getting-big-rotate-them-automatically/
I believe if you use this approach with mongrel, your mongrels will all try to rotate the file at the same time, causing all but the first mongrel to rotate the log to indefinitely block (lock up).
John