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:
Related posts brought to you by Yet Another Related Posts Plugin.
My music selection makes
look good
No images to displayRecent comments
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) [...]