[Twisted-Python] Twisted, twistd and logging

Tim Allen tim at commsecure.com.au
Thu Jun 19 02:21:20 EDT 2008

Hi, all.

I'm working on a new system to be deployed in our production
environment, and having already decided on using Twisted, I'm now
trying to figure out how to cleanly and reliably deploy it. I have many
questions, but right now I just want to work through the issue of

In our existing systems, our code writes messages to syslog, with
'facility' set to LOG_LOCAL0 and 'priority' set according to the
severity of the event - debug, info, warn or alert. Anything logged
with 'alert' severity causes our monitoring to contact the operator on
duty, so they can look into it. For the sake of our operators and
system administrators, I'd prefer to use as much of the existing
monitoring infrastructure as possible. On the other hand, the logging
code we use at the moment is crufty old home-grown code, and I'd much
prefer to use a logging system maintained by somebody else.

My first thought was to use the 'logging' module in the Python 2.3
standard library. It covers all the syslog functionality I want (and
more), and it's pretty easy to use. Unfortunately, using Python's
logging module with Twisted is hard for two reasons: twistd and trial.
Both go to great lengths to Do The Right Thing with logging, and both
totally ignore the Python logging mechanism.

My second thought was to use twisted.python.log, but that brings its
own set of problems:

 1. twisted.python.syslog isn't very... complete. For starters, it
    doesn't let you specify the syslog facility, and even if it did,
    twistd would need to be extended to support it.
 2. As has been discussed in the list archives, t.p.log doesn't support
    log-levels. While I can see glyph's point about the arbitraryness
    of fixed log-levels, I really do want to distinguish between
    "forensic record of ordinary operation" and "Danger, Will Robinson!"

I think the best way of solving my problems would be to:

 a) update t.p.syslog so that it supports a 'facility' parameter.
 b) update t.p.syslog so that log-messages with 'isError' true are
    logged with the LOG_ALERT priority rather than the default.
 c) update the Unix version of twistd to support a 'syslogFacility'
    command-line parameter.

Would such a patch be accepted? If necessary, I could replace (b) with
a syslog-based LogObserver in my own code, but I'm keen to have (a) and
(c) in the Twisted code-base.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20080619/d8062ef1/attachment.pgp 

More information about the Twisted-Python mailing list