Log rotation in Rails apps

Posted on Tuesday, March 21, 2006 in Uncategorized

Logging in Ruby on Rails tends to be a little…verbose. For this site, my production.log had built up to 425MB in 6 months.

Intending to use logrotate, I did a bit of googling and found this instead, which told me Rails could do it for me with the following code snippet:


config.logger = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log", 50, 1.megabyte)

However it doesn’t say where in config/environment.rb to put it. I eventually found this which was more helpful, but still not quite accurate.

So, for the stable version of Typo find the line beginning with RAILS_DEFAULT_LOGGER and replace it with this:


RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log", 50, 1.megabyte)

I’m sure there’s an even better way to do, but this worked for me.

Related posts:

  1. Typo & Ruby on Rails It was my intention to upgrade my weblog software at...
  2. Running Typo svn on Debian Stable (Sarge) After numerous attempts to upgrade this site to the latest...
  3. Summer of Rails meets RailsDay. You installed Ruby on Rails, you bought the...
  4. How to install Ruby on Rails on Ubuntu The instructions for installing Ruby on Rails have always been...
  5. Hosting Rails applications with mongrel , Apache 2 & mod_proxy on Debian Stable About ten months ago I switched from Apache 2 to...

Related posts brought to you by Yet Another Related Posts Plugin.

  1. [...] Log rotation in Rails apps | schwuk.com (tags: rails logs) [...]

My music selection makes last.fm look good

No images to display

This theme was designed by Chris Wallace and is licensed under the GNU General Public License.

Check out his cool WordPress Themes. Released by Six Revisions in the year of the rat.