logging.handlers.SocketHandler

Vinay Sajip vinay_sajip at yahoo.co.uk
Fri Mar 6 04:53:51 EST 2009


On Mar 5, 7:38 pm, writeson <doug.farr... at gmail.com> wrote:
> Hi everyone,
>
> I wrote aloggingserver that receives messages fromlogging.handlers.SocketHandler objects in client Python programs. This
> works well so long as the client programs are start/stop affairs.
> However, if the client is also a long running daemon a problem shows
> up. If theloggingserver is restarted log messages from the daemon
> client go no where, and no errors are thrown. To correct the problem
> the daemon client has to be restarted, then it will reconnect with theloggingserver and all is well. My reading of thelogging.handlers.SocketHandler documentation makes me think this isn't
> how things are supposed to work. Failures of the emit() method (how
> log messages are sent) will close the connection and retry it again at
> the next log message.
>
> By the way, we're running this with Python 2.4 on a CentOS Linux
> server.
>
> Does anyone have any ideas, pointers or suggestions about how to
> address this problem?
>
> Thanks in advance!
> Doug

It may be platform-related. I don't have access to your specific
platform, but I tried with ActivePython 2.5.2.2 on Windows and also
Python 2.5.2 on Ubuntu 8.04 (Hardy Heron). I used the scripts
described in

http://docs.python.org/library/logging.html#sending-and-receiving-logging-events-across-a-network

but modified the client script to place the logging statements in a
"while True:" loop. What I observed on both Windows and Ubuntu was
this: when I killed the socket receiver and restarted it, data from
the client was received by the new receiver process after a short
delay (of a few seconds). I had no need to restart the client to
achieve this.

Can you try testing with these specific scripts in your environment?

Regards,

Vinay Sajip



More information about the Python-list mailing list