My color log configuration

I spent some time making a pretty colored log format that maybe you might like to use as well.

	log http.log.access {
		include http.log.access
		output file /var/log/caddy/access.log
		format formatted "e[35m[{ts}]e[0m e[96me[1m{request>remote_addr}e[0m e[31m{request>headers>X-Forwarded-For}e[0m e[33m{request>method}e[0m e[92m{request>host}e[32m{request>uri}e[0m e[97m{status}e[0m	e[90m{request>headers>User-Agent}e[0m e[34m{request>headers>Referer}e[0m" {
			time_format "02/Jan/2006:15:04:05-0700"
		}
	}
	log {
		exclude http.log.access
		output file /var/log/caddy/caddy.log
		format json
	}

Edit: the forum is replacing the ANSI escape codes with the letter e >:(
So here’s a gist gist:53244678f5290978d19a75ce0f7e0bf6 · GitHub

This goes in the global options and requires caddy to be built with the format-encoder module.

It looks like this :slightly_smiling_face:
image

6 Likes