Skip to content
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

Feature request: Improve log consistency (or provide an easy way to add missing fields) #4054

Closed
udf2457 opened this issue Mar 5, 2021 · 1 comment
Labels
documentation 📚 Improvements or additions to documentation invalid ❓ This doesn't seem right

Comments

@udf2457
Copy link

udf2457 commented Mar 5, 2021

I noticed there is inconsistency between fields extracted into JSON and what's tagged onto the end in common_log, for example, in the "JSON-native" section there is no:

  • duration
  • size
  • status
  • Divisor element of Content-Range
  • Content-Length
  • Content-Type

The reason for this inconsistency unclear, with no mention of it in the docs.

Indeed, many examples in the docs (https://caddyserver.com/docs/caddyfile/directives/log) have common_log delete in them, which puts people under the unsafe assumption that everything potentially useful from common_log is already parsed into JSON when it is not.

The docs also make no mention as to whether it is possible to add extra fields to the standard json output and how this might be done ? e.g. no "standard json output plus these extra fields from common_log " configuration option.

@mholt
Copy link
Member

mholt commented Aug 23, 2021

in the "JSON-native" section there is no:

  • duration
  • size
  • status

That's not true, they do exist in the JSON logs:

zap.Duration("duration", duration),
zap.Int("size", wrec.Size()),
zap.Int("status", wrec.Status()),

  • Divisor element of Content-Range

Where is that in CLF?

  • Content-Length
  • Content-Type

Also not true, as all response headers are logged:

zap.Object("resp_headers", LoggableHTTPHeader(wrec.Header())),

The docs also make no mention as to whether it is possible to add extra fields to the standard json output and how this might be done ?

No, for performance reasons. But a plugin can do that: https://github.com/caddyserver/format-encoder

Thanks for the issue, but going to close as it seems based on a false premise. We can reopen it if there was just a misunderstanding though and there really is a bug or problem here.

@mholt mholt closed this as completed Aug 23, 2021
@mholt mholt added the invalid ❓ This doesn't seem right label Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📚 Improvements or additions to documentation invalid ❓ This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants