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:
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 http://dev.rubyonrails.org/ticket/3512
would seem to indicate that it doesn’t work with recent Rails versions.