Log rotation in Rails apps
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.
About this entry
You’re currently reading “ Log rotation in Rails apps ,” an entry on schwuk.com
- Published:
- 3.21.06 / 1pm
- Category:
- Uncategorized
Comments are closed
Comments are currently closed on this entry.