[New-bugs-announce] [issue1484] logging: callHandlers tests handler levels instead of logger levels?

Gidi Avrahami report at bugs.python.org
Wed Nov 21 23:41:17 CET 2007

New submission from Gidi Avrahami:

I am using the logging module with multiple loggers and the following
behavior seems incorrect to me:

I set the root logger's level to WARN and the foo.bar module's logger's
level to DEBUG, and the foo.bar logger should is writing to a file.  So
basically, I want foo.bar to log itself in details behind the scenes
while the main console is quiet.

However, I still get all the sebug info printed to the console.  When I
trace down the code, I see that callHandlers() is climbing up the logger
hierarchy, but it's comparing record.level to hdlr.level, not to
c.level.  The handler levels, however, don't appear to be set normally
(i.e., after I do getLogger("foo.bar").setLevel, its handlers stay at
level NOTSET).  As a result, callHandlers will call all the handlers
above the first one, no matter what the loggers level.

Is this intentional?  If it is, how should I get the behavior that I
described above?  (I could set propagate=False, but in fact if the rott
logger is DEBUG then I do want it to print the foo.bar messages)

components: Library (Lib)
messages: 57741
nosy: gidi_avrahami
severity: normal
status: open
title: logging: callHandlers tests handler levels instead of logger levels?
type: behavior
versions: Python 2.4, Python 2.5

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list