-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
logging: Implement log_append
handler
#6066
Conversation
1ae34e9
to
6ac1acf
Compare
Wow, I will love this feature |
6ac1acf
to
b52c8b9
Compare
Thanks for this! Maybe bikeshedding, but what about |
Could do But we have |
Love this feature, which is used to add information similar to UserId/ProjectId to the logs without returning it to the client. 👍 |
b52c8b9
to
ed8a19d
Compare
extra_log
handlerlog_add
handler
ed8a19d
to
2834678
Compare
2834678
to
57b7ca0
Compare
log_add
handlerlog_append
handler
We changed our mind again to |
As for
Probably not worth the effort. Different deserializers will handle it differently anyway. |
And it would probably harm performance to do that for little benefit if done at runtime. Unless we check it at provision time or something and warn if they used a "reserved" log key. Can be added later tho. |
57b7ca0
to
7c9a7b5
Compare
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.
Thanks for working on this! :)
I have just built Caddy from the I was already aware that certain directives such as For
Shall I open a separate issue for this? |
Oh oops, you're right, I should've left the old directive names in the directive order. If you want to make a quick PR to fix it, it would save me a few minutes 😅 just needs a |
I am going to try to make this PR to fix it. |
Closes #5336
This adds a new handler
log_append
which adds an extra field to the access logs on the way back up the request chain (after most other handlers have run, including after handler errors).The value may be a placeholder (if the value is surrounded by
{}
) or a vars key (will do a map lookup to see if it exists) or a constant string.Worth noting,
zap
doesn't validate that log fields don't overlap with existing ones when adding, so it's possible to have two log fields with the same name in the logs. For example, you might dolog_append status not-an-int
or whatever and you'd end up with"status": 200, "status": "not-an-int"
in the logs. We could validate that the key is not one of the ones we have built-in, but I'm not sure if that's worth the effort?