BACKTRACE

(condense)

Back to Posts List

GET

Setting up logger options


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:

  1. Rails::Initializer.run do |config|  
  2.   config.logger = Logger.new(File.dirname(FILE “/../log/#{RAILS_ENV}.log”)  
  3. end  


The actual cure for my problem came when i found the option to prevent the logger file from exceeding a pre-defined limit.
  1. 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.
  1. config.logger = Logger.new(File.dirname(FILE) + “/../log/#{RAILS_ENV}.log”“daily”)  


i suggest reading even more on the rails development browser

POST

blog comments powered by Disqus

I Don't have cookies.

ELAD ENV

Variable Value
LINKEDIN
TWITTER
FACEBOOK
GITHUB
WWR
IRC
{ 'irc.freenode.net' => [ '#rubyonrails', '#railsbridge', '#ruby', '#mootools' ]}
SKYPE
eladmeidar

You're seeing this error because I think it is funny.