inveniosoftware / inveniosoftware/invenio-logging

Cannot add debug logging in production

Open
#67 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2
Forks
36
PR merge metrics
No merged PRs in 30d

Description

When in debug mode, we can add logs with levels higher than error/warning. This works:
```python
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](https://github.com/pallets/flask/blob/90967ccb9ab1f757c2637a68ea2e16b8da2605f4/src/flask/logging.py#L71). 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](https://flask.palletsprojects.com/en/2.3.x/logging/#basic-configuration) suggests setting the logging level before app initialization using `from logging.config import dictConfig`.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the production behavior with current_app.logger.debug and app.logger.setLevel(logging.DEBUG), then inspect Flask's linked logging.py location and the dictConfig guidance. The issue does not specify the desired change; done should include an agreed production logging behavior and verification that debug output follows it.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.