# Turning off WEBRick server logging (XMLRPC)

**URL:** <https://www.ruby-forum.com/t/turning-off-webrick-server-logging-xmlrpc/73141>\
**Category:** Ruby\
**Created:** [October 21, 2006, 11:51pm UTC](https://www.ruby-forum.com/t/turning-off-webrick-server-logging-xmlrpc/73141 "2006-10-21T23:51:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adambeazley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@adambeazley](https://www.ruby-forum.com/u/adambeazley)\
**Post date:** [October 21, 2006, 11:51pm UTC](https://www.ruby-forum.com/t/turning-off-webrick-server-logging-xmlrpc/73141/1 "2006-10-21T23:51:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adambeazley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@adambeazley](https://www.ruby-forum.com/u/adambeazley)\
**Post date:** [October 22, 2006, 1:11am UTC](https://www.ruby-forum.com/t/turning-off-webrick-server-logging-xmlrpc/73141/2 "2006-10-22T01:11:11Z")

</div>

On Sun, 22 Oct 2006, Adam B. 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?

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

---

<div class="post-metadata">

**Author:** ![adambeazley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@adambeazley](https://www.ruby-forum.com/u/adambeazley)\
**Post date:** [October 22, 2006, 2:25am UTC](https://www.ruby-forum.com/t/turning-off-webrick-server-logging-xmlrpc/73141/3 "2006-10-22T02:25:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adambeazley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@adambeazley](https://www.ruby-forum.com/u/adambeazley)\
**Post date:** [September 30, 2010, 11:21am UTC](https://www.ruby-forum.com/t/turning-off-webrick-server-logging-xmlrpc/73141/4 "2010-09-30T11:21:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adambeazley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@adambeazley](https://www.ruby-forum.com/u/adambeazley)\
**Post date:** [January 5, 2011, 2:18pm UTC](https://www.ruby-forum.com/t/turning-off-webrick-server-logging-xmlrpc/73141/5 "2011-01-05T14:18:40Z")

</div>

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 =\> [])

---

<div class="post-metadata">

**Author:** ![adambeazley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@adambeazley](https://www.ruby-forum.com/u/adambeazley)\
**Post date:** [January 10, 2011, 10:08pm UTC](https://www.ruby-forum.com/t/turning-off-webrick-server-logging-xmlrpc/73141/6 "2011-01-10T22:08:14Z")

</div>

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 =\> [])
