You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The behaviour you describe is intentional. To achieve what you want, you
can either set levels on the handlers or use Filters on loggers and/or
handlers (if level-based filtering is not sufficient for your needs).
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: