logging.handlers.SocketHandler

writeson doug.farrell at gmail.com
Fri Mar 6 11:09:10 EST 2009


Vinay,

Thanks for the quick response, very much appreciated. I tried the two
scripts you pointed to, modifying the client so it produces log
messages in an endless loop, and it worked fine. If I left the client
running and stopped and started the server, the client would reconnect
and messages would start coming through. This is what you observed and
what is stated in the documentation. Looking at the SocketHandler
Python code shows this would be the behavior as well.

To further complicate my original question, here is more information.
The logging server I created uses Twisted (2.5.0) as it's network
framework and gets network log messages from the clients using Twisted
code. However, once a message is received it is parsed the same way as
the example you pointed, in fact that's what I used as a model to
build the code in my def dataReceived() method of my logging server
Twisted protocol. I don't think there is anything unusual about the
network handling in the Twisted framework.

The client daemons are also Twisted processes, but in their cases they
don't use any Twisted code to send log messages. The log system is
entirely based on the Python logging module, and the
logging.handlers.SocketHandler system specifically. So the clients
should try to reconnect if the server goes down and comes back up. So
I'm a little confused what to try next to resolve the problem I'm
seeing.

By the way, the Python logging system is great, really nice work!
Again, thank you for your quick response and help.

Doug

On Mar 6, 4:53 am, Vinay Sajip <vinay_sa... at yahoo.co.uk> wrote:
>
> 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-log...
>
> 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