logging

Vinay Sajip vinay_sajip at yahoo.co.uk
Tue May 30 12:13:25 EDT 2006


Baurzhan Ismagulov wrote:

> Hello Vinay,
> Ok, here is my hierarchy:
>
[snip]
> [handlers]
> keys=console
[snip]
> [logger_root]
> level=CRITICAL
> handlers=console
>
> [logger_l01]
> level=DEBUG
> qualname=l01
> handlers=console
>
> [logger_l02]
> level=CRITICAL
> qualname=l02
> handlers=console
[snip]

> With the config above, I expect that zzz gets printed, and qqq doesn't.
> When I run the script, zzz is printed twice, and qqq isn't. I want that
> zzz is printed once. How do I do that? I can add a filter if this can't
> be done otherwise, however, I'm at the moment reluctant to do that since
> I don't see why CRITICAL for root passes zzz through and drops qqq
> correctly for l02.

Did you try removing the handler from l01, as I suggested in an earlier
reply? The config above still has the console handler attached to root,
l01 and l02. The reason that zzz is printed twice is that when a logger
decides to process an event, it is passed to handlers attached to
ancestor loggers (unless propagate is set to 0 - but this is not the
normal situation). So, log1 is deciding to process the event (based on
the level), and passing it to its own handlers (l01->console) and then
to its ancestor loggers' handlers (root->console). Remove the handlers
from l01 and l02 and try again.




More information about the Python-list mailing list