[Twisted-Python] How do I turn off certain log messages?
exarkun at divmod.com
Wed May 13 13:02:37 EDT 2009
On Wed, 13 May 2009 17:22:49 +0100, Reza Lotun <rlotun at gmail.com> wrote:
>I was just wondering about the best way to customize twisted logging -
>specifically, I'd like to remove the:
>and "Stopping factory.."
>log messages that pop up whenever I use twisted.web.client
>HTTPClientFactory. Is it simply a matter of writing a custom Logging
>Observer and specifically filtering those kinds of messages?
For this particular case, you can set `noisy´ to False on the factory
and it will stop logging those messages at all.
>I run a
>twisted.web server with twistd (with DailyLogFile) that for every
>connection to it makes a number of web-service calls using web.client.
>I want to have Apache style access logs and be able to spit out error
>conditions *without* anything extraneous creeping in. What are the
>idioms and best practices?
If you'd like a separate http access log, Site supports this if you
tell it where to put it - pass a name for the logPath parameter. That
log file will just get access info (and the info will no longer appear
in your main log).
It is entirely possible to do this the way you suggested - by writing a
custom log observer and either picking just the messages you like to log
or by filtering out any messages you don't like to skip (or any other
custom logic you might like) - but it's probably simpler to use the noisy
feature or the logPath feature, in this case.
More information about the Twisted-Python