Rails Log File Rotation
Posted by Weston Ganger
I found that I had some giant log files that were taking up way to much space. What I needed was log rotation.
You can do this through Linux or through your rails app, I think in the rails app is easier.
Add the following line to config/application.rb
# config/application.rb size = 5*1024 #5MB config.logger = Logger.new(config.paths['log'].first, 5, size)
This tells it to have a maximum of 5 log rotated log files each with a maximum filesize of 5MB.
Also if your production environment runs as root (which it shouldn’t) you may possibly get permission errors and have to resort to the built in linux methods.
Related External Links: