How to set the default log level?

1. Caddy version (caddy version):

v2.1.1

2. How I run Caddy:

Official docker container

3. The problem I’m having:

Followng up on a previous question (How to disable specific logs?) where I discovered that by reading the docs you can actually learn something (a self-RTFM of sorts, specifically how to configure logging for a given site), I am now wondering whether it is possible to set up a default logging level.

All the docs I saw point to https://caddyserver.com/docs/logging and https://caddyserver.com/docs/caddyfile/directives/log. All this suggests that logging is set up on a site basis.

Is it possible to set a global logging level (say, error), and let sites manage the differences?

Yeah there’s a level subdirective to log:

See the syntax right at the top

log {
	output <writer_module> ...
	format <encoder_module> ...
	level  <level>
}

Oh yes , I saw that in the docs. Sorry if I was not clear with my questiion but I am looking for a way to set a global level, applicable to all sites by default (for instance error).

Then the sites which need something different would set it up per your example , at the site level.

In other words, I would like to avoid setting the default level (error) on each site.

There’s no global log config available in the Caddyfile currently. There is the debug global option which sets the log level to debug so that debug logs get written, but obviously that’s not what you need.

You can probably make use of snippets + import args to make it less annoying to write the log config per site.

Thanks, that settles the question!

I already use snippets (lightly) so I will expand them, they are quite powerful actuallt, with the ability to pass arguments.

Thanks again for your help.