Enable access logs globally on all sites using Caddyfile

Alright, so a config like this does work:

{
	log {
		format json
		output stderr
	}
}

http://localhost:8080 {
	log
	respond "Hello, caddy log test world!"
}

The key is you need to at least enable log in each site so that shouldLogRequest is true:

Doing so, it’ll use the default logger instead of configuring a per-site logger, so you can use the global options to configure all of them at once.

2 Likes