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