jump to navigation

Rails log rotations via rsyslog December 25, 2008

Posted by John Dewey in Code, Configuration, Deployment, Example, Rails.

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.


1. pragmatig - March 25, 2009

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)


2. John Dewey - March 25, 2009

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).


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: