Issue 1484: logging: callHandlers tests handler levels instead of logger levels? (original) (raw)

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)