Minimize or disable WEBrick logging
I wrote a simple application today that used WEBrick servlets to serve up some content, and I wanted to minimize the logging that WEBrick puts out.
There are two kings of logging used by WEBrick:
- Server logging, which is controlled by the
:Serverparameter passed toWEBrick::HTTPServer.new. This uses syslog-style log levels. - Access logging, which is controlled by the
:AccessLogparameter. This logs each request, and is similar to the Apache access log.
The default server log level is INFO, but I wanted to change it to WARN. I also wanted to disable Access logging altogether.
include WEBrick
server = HTTPServer.new(
:Port => 8000,
:Logger => Log.new(nil, BasicLog::WARN),
:AccessLog => []
)