handlers.SocketHandler and exceptions

writeson doug.farrell at gmail.com
Wed Jan 16 20:30:00 CET 2008

Hi all,

On our Linux systems at work I've written a Twisted logging server
that receives log messages from multiple servers/processes to post
them to a log file, essentially serializing all the process log
messages. This works well, that is until I tried this test code:

    t = 10 / 0
except Exception, e:
    log.exception("divide by zero")

where log is the logger instance retreived from a call to getLogger().
The problem is the handlers.SocketHandler tries to cPickle.dump() the
log record, which in this case contains an exc_info tuple, the last
item of which is a Traceback object. The pickling fails with an
"unpickleable error" and that's that.

Does anyone have any ideas how to handle this situation? I'd hate to
have to give up using the log.exception(...) call as it's useful to
get strack trace information in the log file.

Thanks in advance,
Doug Farrell

More information about the Python-list mailing list