Peter Marklund

Peter Marklund's Home

Tue March 31, 2009
Programming

Really Simple Rails Log Rotatation

I always used logrotate Linux tool to setup log rotation for my Rails apps which has worked fine although it required finding some external config file and understanding its config options and syntax. I never new log rotation could be set up by adding this one line to config/environments/production.rb right in your app:

config.logger = Logger.new(config.log_path, 50, 1.megabyte)

Sweet!

Comments

Swami Atma said over 5 years ago:

Nice Peter. Good tip.

--------------------------------------------------------------------------------

Adam Meehan said over 5 years ago:

This is a good tip, but if I remember rightly way back when there was talk of it locking up mongrels if more than one tried to rotate the log at the same time.

Its perfect for development and test however. Thanks for the reminder.

Adam

--------------------------------------------------------------------------------

Ashrafuzzaman said over 5 years ago:

Thanks Peter.
It helped a lot :D

--------------------------------------------------------------------------------