Turning off WEBRick server logging (XMLRPC)

I've implemented an XMLRPC server using xmlrpc/server.

I understand that this class encapsulates a WEBRick server. However,
reading through the xmlrpc/server and webrick documentation, I can't
figure out how to turn off the standard access logging. Can anyone
assist?

Thanks!

/adam

···

--
Posted via http://www.ruby-forum.com/.

When you create your webrick httpserver instance, one of the paramters that can be given is :AccessLog. This defaults to stderr if you don't specify it. You can use this to change the logging destination for the access logging.

There is also a :Logger setting that contains the logging destination for the other logging messages.

Kirk Haines

···

On Sun, 22 Oct 2006, Adam Block wrote:

I've implemented an XMLRPC server using xmlrpc/server.

I understand that this class encapsulates a WEBRick server. However,
reading through the xmlrpc/server and webrick documentation, I can't
figure out how to turn off the standard access logging. Can anyone
assist?

Thanks for your response. Yes, I see in the XMLRPC::Server source the
following:

XMLRPC::Server#initialize(port=8080, host="127.0.0.1", maxConnections=4,
stdlog=$stdout, audit=true, debug=true, *a)

So I put in my code

server = XMLRPC::Server.new(3001, "127.0.0.1", 4,
"/tmp/xmlrpcserver.log")

And log output like this DOES go there:

[2006-10-21 16:51:08] INFO WEBrick 1.3.1
[2006-10-21 16:51:08] INFO ruby 1.8.5 (2006-08-25) [i686-darwin8.7.3]
[2006-10-21 16:51:39] INFO WEBrick::HTTPServer#start: pid=4475
port=2001

But the access log lines:

localhost - - [21/Oct/2006:16:33:48 PDT] "POST /RPC2 HTTP/1.1" 200 125
- -> /RPC2

STILL appear on my console (presumably STDOUT).

Indeed, you can see that the two entry types have different time
formats. When I debug the XMLRPC::Server.server.logger.time_format, it's
time_format -- [%Y-%m-%d %H:%M:%S]' -- matches the one that's going to
the right place. So where are the access logs coming from, and how can I
get them under control?

I asked myself.

Looking at the xmlrpc/server.rb source, we see the answer:

630 class Server < WEBrickServlet
632 def initialize(port=8080, host="127.0.0.1", maxConnections=4,
                   stdlog=$stdout, audit=true, debug=true, *a)
633 super(*a)
634 require 'webrick'
635 @server = WEBrick::HTTPServer.new(:Port => port, :BindAddress =>
host,
                                        :MaxClients => maxConnections,
636 :Logger =>
WEBrick::Log.new(stdlog))
637 @server.mount("/", self)
638 end

When the WEBrick server is created, it's not passed anything for the
access log, so it's presumably using the default. Looking at the
webrick/httserver source, I find:

33 unless @config[:AccessLog]
34 @config[:AccessLog] = [
35 [ $stderr, AccessLog::COMMON_LOG_FORMAT ],
36 [ $stderr, AccessLog::REFERER_LOG_FORMAT ]
37 ]
38 end

So that's the culprit -- and it's STDERR, not STDOUT.

Looks like to make this work I'll have to modify lines 632 and 636 of
xmlrpc/server, which I'd rather not do. But at least I understand the
source of the problem.

Thanks again for your help.

/adam

···

When you create your webrick httpserver instance, one of the paramters
that can be given is :AccessLog. This defaults to stderr if you don't
specify it. You can use this to change the logging destination for the
access logging.

There is also a :Logger setting that contains the logging destination
for
the other logging messages.

Kirk Haines

--
Posted via http://www.ruby-forum.com/\.

Have you found a solution to this that did/does not require modifying
library source? I have the exact same issue...

···

So that's the culprit -- and it's STDERR, not STDOUT.

Looks like to make this work I'll have to modify lines 632 and 636 of
xmlrpc/server, which I'd rather not do. But at least I understand the
source of the problem.

--
Posted via http://www.ruby-forum.com/\.

Gal Bar-or wrote in post #944887:

Have you found a solution to this that did/does not require modifying
library source? I have the exact same issue...

So that's the culprit -- and it's STDERR, not STDOUT.

Looks like to make this work I'll have to modify lines 632 and 636 of
xmlrpc/server, which I'd rather not do. But at least I understand the
source of the problem.

solution:

@server = WEBrick::HTTPServer.new(:Port => port, :AccessLog => )

···

--
Posted via http://www.ruby-forum.com/\.

Philippe - thank you, that did the trick... it's amazing how something
so simple can be overlooked and cause such a headache.

Philippe T. wrote in post #972480:

···

Gal Bar-or wrote in post #944887:

Have you found a solution to this that did/does not require modifying
library source? I have the exact same issue...

So that's the culprit -- and it's STDERR, not STDOUT.

Looks like to make this work I'll have to modify lines 632 and 636 of
xmlrpc/server, which I'd rather not do. But at least I understand the
source of the problem.

solution:

@server = WEBrick::HTTPServer.new(:Port => port, :AccessLog => )

--
Posted via http://www.ruby-forum.com/\.