-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Pass request details as log record extra fields #2321
base: master
Are you sure you want to change the base?
Conversation
Same as #2154, just moved to another branch and rebased |
a4b3c87
to
15bdf51
Compare
Is this request still active? |
15bdf51
to
a1cb937
Compare
Is there any chance this will be implemented any time soon? Exactly what I am missing to make log visualisations useful |
@Kludex could you take a look, please? |
I was looking into this and found this open PR. Any chance this can be reviewed and merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see this implemented too!
status_code = message["status"] | ||
status = message["status"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would advice to undo this change. status_code
is used throughout, and reverting it back probably makes it easier to accept this patch! (Also because it makes the diff smaller.)
Summary
I've running an application with uvicorn, and also using python-json-logger to output all production logs in JSON (to pass them to ELK as is, without complicated parsing config).
Here is an example logging config:
So instead of logs like these:
I got these:
Message contains lines like
127.0.0.1:60270 - \"GET /openapi.json HTTP/1.1\" 200
, but I prefer to have separated fieldsclient_address
,method
,full_path
,status
and so on.uvicorn.access
loger already has access to all of this info, but it is logged only in one text fieldmessage
, which I don't want to parse.Instead, I've changed the way
access_log.info
is called - arguments are passed both to message format and toextra
, so they can be accessed by other log formatters fromLogRecord
object. The result is:Checklist