I have created a simple Python XML-RPC implementation, largely based on the examples.
However, it sends output like this:
foo.bar.com - - [13/Feb/2010 17:55:47] "POST /RPC2 HTTP/1.0" 200 -
… to the terminal, even if I redirect standard out and standard error to a file using >> or >. I’m doing this with the following line:
python foobar 2>&1 >> foobar.log
It seems almost like it’s not sending to standard out, but somewhere else.
Also, when an exception occurs on recieving a request, the whole application crashes with this error:
----------------------------------------
Exception happened during processing of request from ('1.2.3.4', 51284)
How can I handle this exception? I need to recover gracefully, and just log the exception message rather than the server crashing.
I guess you’re using the
SimpleXMLRPCServerclass from the examples. In that case, simply provide the parameterlogRequestswhen creating it:That will suppress request logging.
As for the exceptions, they’re logged in
BaseServer(cf. source code of “SocketServer.py”):As you can see, the first part is written to stdout, which is why
&2>1didn’t work completely. If you want to suppress them, override or overwrite that method.