Yun Mao <maoy+twisted@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,127.0.0.1] 127.0.0.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 fine. E.g., if you use to do the typical: from twisted.python import log log.startLogging(somefile) 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) log.startLoggingWithObserver(NoHTTPLogFileObserver(sys.stdout).emit) 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