logging

ibr at radix50.net ibr at radix50.net
Tue May 30 17:41:52 EDT 2006


Hello Vinay,

On Tue, May 30, 2006 at 09:13:25AM -0700, Vinay Sajip wrote:
> [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]
...
> > When I run the script, zzz is printed twice, and qqq isn't. I want that
> > zzz is printed once.
...
> Did you try removing the handler from l01, as I suggested in an earlier
> reply?

I had removed the whole line, and it complained about the missing
handlers line. Now I've tried with 'handlers=', this seems to work.
Thanks much!


> 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).

Hmm, log1 decides once whether to print an event, and after that it gets
printed in log1 and all its ancestors, regardless of their level? I find
this quite counter-intuitive. I'd instead expect that each logger
decides whether to print an event according to its own level. Could you
give an example why one would want the python behavior?


With kind regards,
Baurzhan.



More information about the Python-list mailing list