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.
Related posts:
- Typo & Ruby on Rails It was my intention to upgrade my weblog software at...
- Running Typo svn on Debian Stable (Sarge) After numerous attempts to upgrade this site to the latest...
- Summer of Rails meets RailsDay. You installed Ruby on Rails, you bought the...
- How to install Ruby on Rails on Ubuntu The instructions for installing Ruby on Rails have always been...
- 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.
My music selection makes
look good
No images to display Recent comments
- accountinghomework help: Good website in your company and this is important thought for our business. Tha...
- erniejunior: Hello, I also have a compaq mini 700 and I had problems with upgrading from u...
- David Barnes: Two options: Google Sites and Ning. Ning makes it easy to create something that ...
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.
03 Jun 2008 12:17 am
[...] Log rotation in Rails apps | schwuk.com (tags: rails logs) [...]