开发者

rails log rotation behaves weird (rails version 2.3.5)

开发者 https://www.devze.com 2022-12-31 04:26 出处:网络
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)

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 r开发者_C百科ails is writing to them randomly and at the same time as well. This creates messy log files :-( what am I missing?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号