V2 Logging format

1. My Caddy version (caddy version):

v2.0.0-rc.3

2. How I run Caddy:

a. System environment:

Linux Debian Buster

d. My complete Caddyfile or JSON config:

gaubert:80 {
	root * /var/www
	file_server
	import common.conf
}

# common.conf
php_fastcgi unix//var/run/php/php7.3-fpm.sock
encode gzip

log {
	output file /var/log/caddy/access.log
	# format single_field common_log
}

3. The problem I’m having:

Note really a problem, but questions:

  • with the log config above, caddy is still replicating the very same log message in syslog. A bit redundant.

  • Also, when trying to change the format log to format single_field common_log user agent information does not show up. I could live with the default json output, a lot richer, but the “classical | archaic” format is much more readable when I need a quick glance to the log. Any suggestions?

If I refer to my v1 log directive it reads:

log / /var/log/caddy/access.log "{remote} {when_iso} {proto} {status} {method} \"{uri}\""{
        rotate_size 50  # Rotate after 50 MB
        rotate_age  90  # Keep rotated files for 90 days
        rotate_keep 20  # Keep at most 20 log files
        rotate_compress # Compress rotated log files in gzip format
}

You can read how logging works here: How Logging Works — Caddy Documentation and here: JSON Config Structure - Caddy Documentation

Right, that’s because the common log format does not include user agent. I complain about this in our logging page: How Logging Works — Caddy Documentation

Actually @nicolinux posted a Wiki article that explains how to do this: Making Caddy logs more readable

1 Like

For ref, that wiki page:

1 Like

Ok. I have read all the doc about logging and I kind of understand it. Couldn’t find the config option that could prevent caddy to write to syslog when the log writer output is a file though. Not a big deal, just curious.

Thanks for the link to jq.

Cheers

Jean-Luc

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