禁用 webrick 的回显
如何禁用来自 webrick 的消息回显到终端?对于开头出现的 INFO
消息,我可以通过设置 Logger
参数来禁用它,如下所示:
s = WEBrick::HTTPServer.new(
Port: 3000,
BindAddress: "localhost",
Logger: WEBrick::Log.new("/dev/null"),
)
但我还想禁用如下所示的消息:
本地主机 - - [17/Jun/2011:10:01:38 美国东部夏令时间]“获取...HTTP/1.1”200 0 http://localhost:3000/ -> ......
当从网络浏览器发出请求时。
How can I disable messages from webrick echoed on to the terminal? For the INFO
messages that appear at the beginning, I was able to disable it by setting the Logger
parameter so as:
s = WEBrick::HTTPServer.new(
Port: 3000,
BindAddress: "localhost",
Logger: WEBrick::Log.new("/dev/null"),
)
But I further want to disable the messages that look like:
localhost - - [17/Jun/2011:10:01:38
EDT] "GET .... HTTP/1.1" 200 0
http://localhost:3000/ -> .....
when a request is made from the web browser.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
点击链接到源和提供的建议又一个极客,我找到了一种方法。将
AccessLog
参数设置为[nil, nil]
[]
(根据 Robert Watkins 的建议进行了更改)。Following the link to the source and suggestion provied by Yet Another Geek, I was able to figure out a way. Set the
AccessLog
parameter to[nil, nil]
[]
(Changed following suggestion by Robert Watkins).