Skip to content

Cannot add debug logging in production #67

@ntarocco

Description

@ntarocco

When in debug mode, we can add logs with levels higher than error/warning. This works:

current_app.logger.debug("this is a debug log")

However, when in "production" (DEBUG is False), Flask will not change the level of the root logger, see here. As a consequence, any log higher than .error or .warning will not propagate to the specific handlers, so no logging output.

To test this, setting app.logger.setLevel(logging.DEBUG) fixes current_app.logger.debug.

The Flask documentation suggests setting the logging level before app initialization using from logging.config import dictConfig.

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