Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add debug logging in production #67

Open
ntarocco opened this issue Aug 25, 2023 · 0 comments
Open

Cannot add debug logging in production #67

ntarocco opened this issue Aug 25, 2023 · 0 comments

Comments

@ntarocco
Copy link

ntarocco commented Aug 25, 2023

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.

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

No branches or pull requests

1 participant