[Twisted-web] Re: How to get rid of web logs?

David Bolen db3l at fitlinxx.com
Thu Sep 30 16:51:38 MDT 2004

Yun Mao <maoy+twisted at cis.upenn.edu> writes:

> Right now I'm using the log for debugging, and I don't wan to log those
> info like below. How should I achieve this?  Thanks!
> 2004/09/30 13:31 Eastern Daylight Time [HTTPChannel,1,]
> - - [
> 30/Sep/2004:17:31:56 +0000] "GET /?view=all HTTP/1.1" 200 2767
> "http://localhost
> :1083/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7)
> Gecko/20040803
> Firefox/0.9.3"

You could set up your own log observer (based on log.FileLogObserver
for simplicity) and filter out anything where the system entry in the
event dictionary started with HTTPChannel.  It does have a dependency
if HTTPChannel changes its prefix in the future, but it should work

E.g., if you use to do the typical:

    from twisted.python import log


switch it to:

    from twisted.python import log

    class NoHTTPLogFileObserver(log.FileLogObserver):
        def emit(self, eventDict):
            if not eventDict.get('system','').startswith('HTTPChannel'):
                log.FileLogObserver.emit(self, eventDict)


Alternatively, you can use your own observer to do anything you want
with those.  For example, in one of our applications, we just filter
out the HTTPChannel events to a separate log file whereas most of the
log messages go to a central log.

-- David

More information about the Twisted-web mailing list