禁用Webrick的回显

禁用Webrick的回显

本文介绍了禁用Webrick的回显的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何禁用来自回传到终端的webrick的消息?对于开头出现的INFO消息,我可以通过设置Logger参数将其禁用,例如:

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:

从网络浏览器发出请求时.

when a request is made from the web browser.

推荐答案

链接到和另一位极客提出的建议,我找到了一种方法.将AccessLog参数设置为 [](根据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 [] (Changed following suggestion by Robert Watkins).

s = WEBrick::HTTPServer.new(
  Port: 3000,
  BindAddress: "localhost",
  Logger: WEBrick::Log.new("/dev/null"),
  AccessLog: [],
)

这篇关于禁用Webrick的回显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 22:30