要解决损坏的Rails记录器(不接受log_tags)的问题,可以尝试以下方法:
gem install rails
config/environments/production.rb
文件中,检查以下设置:config.log_tags = [:subdomain, :uuid]
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
config/application.rb
文件中,添加以下代码:class CustomLogger< ActiveSupport::Logger
def initialize(*args)
super
@formatter = proc do |severity, datetime, progname, msg|
"#{datetime.to_s(:db)} #{severity} -- : #{msg}\n"
end
end
end
config.logger = CustomLogger.new(STDOUT)
Lograge
。要安装Lograge
,请运行以下命令:gem install lograge
然后,在config/application.rb
文件中,添加以下代码:
config.lograge.enabled = true
config.lograge.custom_options = lambda do |event|
{
time: event.time,
params: event.payload[:params].except('controller', 'action', 'format', 'utf8', 'authenticity_token', 'commit', 'controller', 'action')
}
end
log_tags
。如果有,请将其替换为tagged_logging
。如果问题仍然存在,请查看Rails文档以获取更多信息,或者在社区论坛中寻求帮助。
领取专属 10元无门槛券
手把手带您无忧上云