Propagate Gunicorn Uvicorn worker logs - #156
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Uvicorn worker class originally disabled propagation because it resulted in duplicate logs if enabled (Kludex/uvicorn#614, Kludex/uvicorn#623). As the docs on
logging.Logger.propagateexplain, "If you attach a handler to a logger and one or more of its ancestors, it may emit the same record multiple times."inboard/inboard/gunicorn_workers.py
Lines 54 to 62 in 68ceb47
Instead of disabling propagation and keeping Gunicorn handlers set on the logger, another solution is to remove the Gunicorn handlers and enable propagation so the root logger can manage all logs (#131). This would be closer to the intent expressed in the current logging docs: "Uvicorn, Gunicorn, and FastAPI log streams are propagated to the root logger, and handled by the custom root logging config."
Changes
This PR will update the Gunicorn Uvicorn worker to remove handlers from
uvicorn.erroranduvicorn.accessand instead propagate those log records to the root logger. This will avoid duplicate records and ensure the root handler applies the configured formatter and filters.Related
logging.Logger.propagate