Disabling echo from webrick

假如想象 提交于 2019-11-30 22:34:59

问题


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.


回答1:


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).

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


来源:https://stackoverflow.com/questions/6387087/disabling-echo-from-webrick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!