I put mine in application.rb because it is only a few lines. I am lazy. If you put your class in a file in lib /, you will have to manually either it or configure lib / autoloading.
Here is my registrar code:
application.rb:
class DreamLogFormatter < Logger::Formatter
def call(severity, time, progname, msg)
"[%s(%d)%5s] %s\n" % [time.to_s(:short), $$, severity, msg2str(msg)]
end
end
....
config.logger = Logger.new(Rails.root.join('log', "#{Rails.env}.log"), 10, 30*1024*1024)
config.logger.formatter = DreamLogFormatter.new
Please note that I roll logs every 30 MB and keep the last 10 logs.
source
share