views:

75

answers:

1

I'm trying to setup log rotation in rails. I have put this in my environment/development.rb:

config.logger = Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 1, 5*1048576)

2 files are created :-) but it looks like rails is writing to them randomly and at the same time as well. This creates messy log files :-( what am I missing?

A: 

My guess is that you restarted the server before the log file is full (5mb) and when you run the server again, it creates a new file, which makes it confused in which file to write.

Possible solution is to delete both file and try it again or you can always increase the number of old log file to more than 1.

config.logger = Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 10, 5*1048576)

Hopefully it helps.

SamChandra
Thanks for your quick response. I have not restarted the server, the first logfile fills up nicely, but when there are 2 files, it starts writing to them randomly. Very strange...
robodo
it does not happen when I run script/server, maybe it is related to passenger...
robodo