[V2] custom logging

I am trying to simplify the json log output by using the format modules, but I couldn’t find any example or documentation about the possible values for the log “keys”.

I have looked into the json encoder doc and there is no info about the allowed values for the log keys.

What would be the log directive(s) if I only want e.g. these fields:

  • ts (with a custom date/time format)
  • uri
  • proto
  • http response code (status)
  • user agent

I know I could use jq to filter out the json log, but this is an extra step I want to avoid. I am happy to use the json encoder after having read this argumentation, but there are a lot of informations in the json default output that I don’t need and that I will never use.

The docs on the website haven’t quite been updated yet with the latest from Github, but I think this is what you’re asking for:


But frankly, since the filter encoder only lets you exclude fields and not “keep only” (I’ve tried to implement it… it’s non-trivial unfortunately, see [FEATURE][v2]: Provide a new "allow_list" to the log filter · Issue #3562 · caddyserver/caddy · GitHub), I don’t think this’ll do it for you.

Ultimately I think using a tool like jq is the best option.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.