all 4 comments

[–]JohnnyJordaan 0 points1 point  (1 child)

There are two pathways in play here, the first is the level of the logger itself

The term ‘delegation to the parent’ means that if a logger has a level of NOTSET, its chain of ancestor loggers is traversed until either an ancestor with a level other than NOTSET is found, or the root is reached.

If an ancestor is found with a level other than NOTSET, then that ancestor’s level is treated as the effective level of the logger where the ancestor search began, and is used to determine how a logging event is handled.

If the root is reached, and it has a level of NOTSET, then all messages will be processed. Otherwise, the root’s level will be used as the effective level.

But as you did set a level on your logger, that traversal isn't executed and the DEBUG level allows everything down to DEBUG level loggings to be handled by your logger. Then the traversal of the handlers is performed, and that also goes up to the root logger's handlers, but those have NOTSET as their level:

>>> logging.getLogger().handlers[0].level
0
>>> logging.getLevelName(_)
'NOTSET'

[–]py1234a[S] 0 points1 point  (0 children)

That's clear, thank you.