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
Inconsistent logging initialization #1969
Comments
abitrolly
changed the title
Inconsistent logging configuration
Inconsistent logging initialization
Nov 16, 2020
abitrolly
added a commit
to chubin/cheat.sh
that referenced
this issue
Nov 17, 2020
Sometimes there is nothing, sometimes lines are duplicated. Duplicated lines problem appears, because Python root logger handler and Flask's `werkzeug` logger handler both write the same message. `cheat.sh` is hit, because it sets this root logging handler. Normally `werkzeug` doesn't setup its own handler if it sees that there are some handlers that process its messages. This in case of `cheat.sh` resulted in no stderr logging at all. No Exceptions either. Because `werkzeug` catches the exceptions and logs them. Hovewer, sometimes `werkzeug` starts too early, befora app is imported (pallets/werkzeug#1969) and sets its logger anyway, before the app itself, resulting in duplicating lines. In that case app root handler needs to skip lines from `werkzeug`. Kudos to @brandon-rhodes for `logging_tree` awesomeness
If
|
I can't reproduce this with the latest code. Seems likely to have been addressed by #1500. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
werkzeug
sometimes initializeslogging
before app import, resulting in double logging entries.This is
app1.py
that useslogging_tree
to print logging configuration.The application is run with
flask run
in development mode.Then, using combination of
touch app1.py
andcurl localhost:2999
it should be easy to catch condition when after `logging`` tree is not empty, and log lines are duplicated. Here is the output. What happens there.werkzeug
reloadedapp1.py
.app1.py
found no logging configuration, implicitly installed own root handler throughlogging.warn
. When request fromcurl
arrived, it was logged with this root handler asINFO:werkzeug:127.0.0.1..
line. No other lines with 200 status are printed so far.touch
event madewerkzeug
reloadapp1.py
again. This time the logging configuration appears non-empty,app1.py
again adds root handler, and when request arrives, it is printed twice.I expected
werkzeug
to initialize the logging module afterapp
is imported to prevent double entries instderr
logs.Environment:
The text was updated successfully, but these errors were encountered: