Skip to content

Propagated logs with lower level get logged in the parent logger #139878

@frostming

Description

@frostming

Bug report

Bug description:

import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.NullHandler())

logging.basicConfig()  # set formatter and handler for root logger(WARNING level)

logger.debug("This is a debug message")  # Should this be logged?

As title, if I logged a message with matching level on the child logger, the message will also be propagated to the parent, even if the parent logger has a higher level configured.

Actual Result

DEBUG:__main__:This is a debug message

Output log from the root logger.

Expected Result

The message should not be printed since root logger has WARNING level

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions