rack-timeout: turn off info/active logging

扶醉桌前 提交于 2019-12-05 21:15:35

(Note the class name was changed from Stage… to State… in v0.3.0)

In production I want to log at INFO level so I get a log message per request, but I don't want this noise from rack-timeout.

You can alter the STATE_LOG_LEVEL hash in the StateChangeLoggingObserver and change the log level used for the different states. I use this in my initialiser to prevent the ready and completed logs from showing:

Rack::Timeout::StateChangeLoggingObserver::STATE_LOG_LEVEL[:ready] = :debug
Rack::Timeout::StateChangeLoggingObserver::STATE_LOG_LEVEL[:completed] = :debug

My solution to this problem was to give rack-timeout its own logger.

Once you've done that, you can change its log level:

# config/initializers/timeout.rb
Rack::Timeout::Logger.logger = Logger.new("log/timeout.log")
Rack::Timeout::Logger.logger.level = Logger::ERROR

Read here for more information

https://github.com/heroku/rack-timeout#rails-apps-manually or https://github.com/heroku/rack-timeout/blob/master/doc/settings.md

You could also try this code, though untested.

Rack::Timeout::StageChangeLoggingObserver.logger = logger = ::Logger.new(STDERR)
logger.level = ::Logger::DEBUG
logger.formatter = ->(severity, timestamp, progname, msg) {"[#{timestamp}] #{msg} at=#{severity.downcase}\n" }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!