Forum: Ruby on Rails Log rotation

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Pete Y. (Guest)
on 2006-04-10 10:26
(Received via mailing list)
Using Logger's standard log rotation in a production Rails app fails,
and I'm looking for the easiest way around the problem.

Currently, I'm using this in environment.rb:"#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 'daily')

but sometimes get this showing up in the browser:

   Shifting failed. '.../production.log.20060406' already exists.

followed by a backtrace.

Some debugging and a look at the Logger code leads me to the
conclusion that the following is happening:

One dispatcher rotates the log file and opens a new one, but the
other dispatchers still have the original file open. When requests
arrive at the other dispatchers, they try to rotate the file and fail
because it's already been done.

Is there some Logger magic that I'm missing that would make this
work, or do I need to have an external script do the rotation and
then restart my Rails app?

I had a look at log4r but
would seem to indicate that it doesn't work with recent Rails versions.


Pete Y.
This topic is locked and can not be replied to.