Skip to content

Consider not using the root logger #1138

@spezialspezial

Description

@spezialspezial

I would like to suggest to not use the root logger for logging. Instead consider using something like:

import logging
logger = logging.getLogger(__name__)
...
logger.info(f"Found gold in the factory basement: {worth=}$")

It would make redirecting more convenient.

Also, to quote the elders of python:

Note: It is strongly advised that you do not log to the root logger in your library. Instead, use a logger with a unique and easily identifiable name, such as the name for your library’s top-level package or module. Logging to the root logger will make it difficult or impossible for the application developer to configure the logging verbosity or handlers of your library as they wish.

Let me know what you think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions