Caddy v2 Logs: How to limit output?

1. Caddy version (caddy version):


2. How I run Caddy:

a. System environment:

Ubuntu 18.04

3. The problem I’m having:

I’m looking at the v2 log docs and I don’t understand how to choose specific things to log or not log.

For example, I’d like to print something like this:

<method> <response code> <path> <referer>

I don’t want to log all cookies and all headers, etc, but rather just a few things.

5. What I already tried:

Not even sure what to try.

6. Links to relevant resources:

Hey AJ,

You can read about logging here: How Logging Works — Caddy Documentation

Basically: the logs are structured, so just ignore the fields or lines you don’t want. That is the easiest, and highest-performance way.

I’m not quite sure I understand.

Ultimately, log processing is out of the scope of Caddy core.

there’s always the possibility for a Caddy app module that consumes logs. (It just doesn’t exist yet

Are you saying that the correct and expected way is for me to write a Caddy logger plugin in Go that follows logfmt? That there is no configuration?

I see there’s some documentation on filters here:

But I’m not clear on how that relates to a Caddyfile or the API.

I realize that with the switch to v2 there are a lot of changes to prior conventions and it will be a while before all of the modules are updated with specific examples. It looks like the “meta” examples are pretty much all there, but it’s still a bit challenging to figure out how they apply to a use case.

Is there a repository of example Caddyfiles or curl commands that cover how to use the various modules in a more concrete way?

Since you first asked this, a new plugin was written to help cover this usecase:

Note that it’s more expensive to run than the core capabilities. Probably won’t be an issue unless you get to truly huge scale.

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