我的rails logger配置当前记录当前时间和UUID,如下所示:
config.logger = ActiveSupport::TaggedLogging.new(Logger.new("#{Rails.root}/log/#{ENV['RAILS_ENV']}.log",'daily')) config.log_tags = [Proc.new {Time.now.strftime('%Y-%m-%d %H:%M:%S.%L')},:uuid]
有没有办法记录当前消息的日志级别?
解决方法
Railscasts显示如何通过覆盖SimpleFormatter#调用方法来覆盖记录器以输出日志消息的严重性:
class Logger::SimpleFormatter def call(severity,time,progname,msg) "[#{severity}] #{msg}\n" end end
有关详细信息,请参阅http://railscasts.com/episodes/56-the-logger-revised.