Backup strategy for production.log of Rails application

Usually you will find the size of your rails application is huge after some time because by default rails maintains each an every activity done on application in log file.

How you will maintain production.log file here is the simple step:

Copy the following code in your config/application.rb file

config.logger = Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 100, 200 * 1024  * 1024)

What above code does is, it keep watch on production.log file once the size of file becomes 200 MB it moves the log to production.log.0 and so on till 100 files. After 100 files its starts overriding the log.

Note: Threshold value for log and Number of files can be changed, just by editing 2nd and 3rd parameters from Logger.new

One thought on “Backup strategy for production.log of Rails application

Leave a comment