Hi Chris,

Filtering is intended to be for cases where integer level-based filtering is 
insufficient; hence it applies to individual loggers and handlers, just as the 
integer levels do.  You are right that you would need to add a filter to all of 
the loggers where you want it to apply, or to all of the handlers where you 
want it to apply. However, if you find your usage pattern occurring very 
commonly in your applications, it's easy enough to create a DelegatingHandler 
handler class which passes its events on to any number of handlers you like. 
You can then apply the filter you want to an instance of this handler, which 
you attach to your root logger.
Regards,


Vinay Sajip


----- Original Message -----
> From: Chris Withers <ch...@simplistix.co.uk>
> To: Vinay Sajip <vinay_sa...@yahoo.co.uk>
> Cc: Python List <python-list@python.org>
> Sent: Monday, 16 January 2012, 13:10
> Subject: python loggingL filter limitation, looks intentional?
> 
> Hi Vinay,
> 
> It looks like this was intentional, so why was it decided that filters would 
> only be passed messages logged to the logger they're attached to rather than 
> the all messages that end up getting passed to logger?
> 
> For example, an app and the libraries it uses log to 'some.db.driver', 
> 'some.lib' and 'myapp'.
> 
> The root logger has a number of handlers attached to it.
> 
> I want to write a filter that adjusts, up or down, the level of certain 
> messages 
> logged based on a regex match of their message.
> 
> If I understand correctly, I have to add my filter to all of the loggers 
> above, 
> rather than just the root logger where my handlers live?
> 
> Or, alternatively, add the filter to all of the root handlers, thereby making 
> the configuration of those handlers and/or more dependent on each other.
> 
> Why is that?
> 
> cheers,
> 
> Chris
> 
> -- Simplistix - Content Management, Batch Processing & Python Consulting
>             - http://www.simplistix.co.uk
> 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to