[TIP] Specifying custom logging options

Subscribe to [TIP] Specifying custom logging options 0 post(s), 1 voice(s)

 
Avatar rick Administator 546 post(s)

If Warehouse runs for awhile, you’ll fill up your application’s log over time. Here’s how you can customize it if you want to.

  1. Open up config/environment.rb
  2. find line #13, starting with Rails::Initializer.run do |config|
  3. underneath that enter this line of code:
config.logger = Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 5)

What that does is creates a rotation of five log files with a maximum size of 1MB. You can configure this in several ways:


# rotation of five log files at 5MB each (1024 * 1024 * 5).
config.logger = Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 5, 5242880)

# rotate logs daily, weekly, or monthly
config.logger = Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 'daily')

I’ll probably set it to something similar by default in Warehouse v1.1.