[Mongrel] Log rotation

Carl Lerche carl.lerche at gmail.com
Mon Oct 9 14:40:20 EDT 2006

You can do something like this in environment.rb

config.logger =
Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 50, 4194304)

Check the docs for Logger for more information.


On 10/1/06, David Vrensk <david at vrensk.com> wrote:
> Hi mongrel-herders,
> I'm just wondering what fellow railsers use to rotate their logs in an
> orderly fashion?  I'd like to do something lightweight, i.e. (1) rename the
> logfile (2, optional) create a new empty logfile and (3) send a signal to
> each mongrel in the cluster and have them understand it's time to reopen
> their log file handles.  This is what I do with apache and nginx and loads
> of other apps.
> Although the question is simple as stated, let me elaborate a little to
> avoid having the discussion going the wrong way (rein it in, as it were):
> 1. I'm really only concerned about production.log, since that is the big
> file.  A solution that lets me rotate mongrel.log too is fine, but not
> necessary.
> 2. I know I can send a SIGUSR2 to each mongrel (or do a mongrel_cluster
> restart) to restart mongrel, but I'm running on a low-end machine which
> takes no less than 30 seconds to start rails, so I'd rather avoid the
> overhead.  And even if it didn't, I think most of us agree that there's no
> real point in stopping out app even for a second just to reopen a file
> handle.
> 3. I realise that mongrel isn't rails-bound, so it might not be mongrel's
> responsibility to make rails switch log files.  In that case, please point
> me in another direction and I'll see what I find.
> 4. I see that I can send a SIGHUP to mongrel which might make it do the
> right thing, but the caveat "(Internal reload) that might not work so well."
> is all but encouraging.
> Seeing as I've come this far, perhaps I should take a step back and ask:
> what do fellow mongrel_railsers use for logging?  Logger? Log4R?  Something
> else entirely?  And what made you decide on the solution you use?
> Hope you haven't choked on my ramblings, and I look forward to your
> collective wisdom!
> /David
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users

More information about the Mongrel-users mailing list