本文介绍了机架超时:关闭信息/活动日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装了 rack-timeout gem的情况下可能只显示错误的相关日志?例如,我想避免在日志中包含以下内容:

With the rack-timeout gem installed how is it possible to display ERROR only related logs? For example I would like to avoid having the below in my logs:

source=rack-timeout id=8a11a8ac3dadb59a4f347d8e365faddf timeout=20000ms service=0ms state=activesource=rack-timeout id=8a11a8ac3dadb59a4f347d8e365faddf timeout=20000ms service=49ms state=completedsource=rack-timeout id=ee947d4a291d02821ab108c4c127f555 timeout=20000ms state=ready

source=rack-timeout id=8a11a8ac3dadb59a4f347d8e365faddf timeout=20000ms service=0ms state=activesource=rack-timeout id=8a11a8ac3dadb59a4f347d8e365faddf timeout=20000ms service=49ms state=completedsource=rack-timeout id=ee947d4a291d02821ab108c4c127f555 timeout=20000ms state=ready

以下内容无效:Rack::Timeout.unregister_state_change_observer(:active)

以下内容可能在正确的路径上,但我无法进行测试:

The below may be on the right path but I'm having trouble testing:

Rack::Timeout::Logger.level = Logger::ERROR

推荐答案

我对此问题的解决方案是为rack-timeout提供自己的记录器.

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

这篇关于机架超时:关闭信息/活动日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 08:19