Skip to content

Conversation

@ThomasFarstrike
Copy link
Contributor

The handler's level was being set to the root logger's level in basicConfig(), which prevented child loggers from setting their own levels. This violated the standard logging architecture where handlers should not filter by level - that's the logger's responsibility.

Changed handler.setLevel(level) to handler.setLevel(NOTSET) in basicConfig() so that handlers pass through all messages and let loggers control filtering.

This allows code like:
logger = logging.getLogger("myapp")
logger.setLevel(logging.INFO)
logger.info("message") # Now works correctly

Previously, INFO messages would be filtered out if the root logger was at WARNING.

Fixes: Child loggers unable to log at levels lower than root logger's level

The handler's level was being set to the root logger's level in basicConfig(),
which prevented child loggers from setting their own levels. This violated the
standard logging architecture where handlers should not filter by level - that's
the logger's responsibility.

Changed handler.setLevel(level) to handler.setLevel(NOTSET) in basicConfig()
so that handlers pass through all messages and let loggers control filtering.

This allows code like:
  logger = logging.getLogger("myapp")
  logger.setLevel(logging.INFO)
  logger.info("message")  # Now works correctly

Previously, INFO messages would be filtered out if the root logger was at WARNING.

Fixes: Child loggers unable to log at levels lower than root logger's level


Signed-off-by: Thomas Farstrike <111072251+ThomasFarstrike@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant