V2: How to get proper logging working?

I try to get proper logging in Docker but it is a total mess. The documentation is rudimentary which doesn’t help figure out how to configure.

I have a log directive but I still get tons of message on stdout/stderr

   log {
      output file /caddy/srv/access.log {
         roll_size 200MiB
         roll_keep 5
      }
   }

Most messages seen in docker logs are not in the log. How to get everything in the log ?

Command to start caddy: /caddy/bin/caddy run --environ --watch --config /caddy/etc/Caddyfile

How to format the log for easy reading ? As is it’s just massive blocks of text that are extremely hard to read.

Thanks

Edit: Sorry for the rude tone. Being unable to find something useful in the documentation, like more details or more examples, really got on my nerve :slightly_frowning_face:

Hi @MorgothSauron!

The log Caddyfile directive is for per-site access log output configuration. It doesn’t affect the default logging that you’re seeing in stdout/stderr. The details on the log Caddyfile directive are here: log (Caddyfile directive) — Caddy Documentation

I recommend going over the article we have explaining this, specifically the part about the logging pipeline in Caddy. It touches a little bit on the difference: How Logging Works — Caddy Documentation

The logging article links additionally to the JSON logging configuration, which has details and explanation of how to configure the default logger, which is what you’re seeing on stdout/stderr: JSON Config Structure - Caddy Documentation

1 Like

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