i was called the other day about one of my past projects server going down because it's production log exceeded 2GB.
regularly, there is a cron job to cycle the log file and prevent such joyous occasions, but for some reason it didn't happen. so i decided to read a little bit about the Logger class in Rails and see if it has some magic for me yet.
in order to replace the log file path (and/or name) use the following syntax in environment.rb:
- Rails::Initializer.run do |config|
- config.logger = Logger.new(File.dirname(__FILE__) + "/../log/#{RAILS_ENV}.log")
- end
The actual cure for my problem came when i found the option to prevent the logger file from exceeding a pre-defined limit.
- config.logger = Logger.new(File.dirname(__FILE__) + "/../log/#{RAILS_ENV}.log", 1, 2*1024*1024)
and a little extra for creating a brand new log file for each day.
- config.logger = Logger.new(File.dirname(__FILE__) + "/../log/#{RAILS_ENV}.log", "daily")
i suggest reading even more on the rails development browser
1 comments:
September 23, 2007 at 6:43 AM
hello !
nice, kewl way :)
also u can insert "%d-%M-%Y" for daily-style log :)
Post a Comment