Config cleanup for logging, blocking, and a signalr issue

I rebuilt my docker image with this Dockerfile:

FROM caddy:2.7.6-builder-alpine AS builder

RUN xcaddy build v2.7.6 \
    --with github.com/caddyserver/caddy/v2=github.com/caddyserver/caddy/v2@multi-loggers \
    --with github.com/caddy-dns/cloudflare@latest \
    --with github.com/caddyserver/transform-encoder \
    --with github.com/sjtug/caddy2-filter

FROM caddy:2.7.6

RUN apk add --no-cache tzdata

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

And my existing log-both snippet works as expected, logging to both files simultaneously. You’ve solved this niche corner case quite nicely. Hopefully it gets into v2.8!

The snippet for posterity:

(log-both) {
	log {args[0]}-common {
		hostnames {args[0]}
		output file /opt/log/caddy/{args[0]}
		format transform `{request>client_ip} - {request>user_id} [{ts}] "{request>method} {request>uri} {request>proto}" {status} {size} "{request>headers>Referer>[0]}" "{request>headers>User-Agent>[0]}"` {
			time_format "02/Jan/2006:15:04:05 -0700"
			time_local
		}
	}

	log {args[0]}-json {
		hostnames {args[0]}
		output file /opt/log/caddy/{args[0]}.json
		format json {
			time_local
		}
	}
}

Which I’ve added to my handler snippet block like

import log-both ip.foreveratroll.com

I’m gonna go back to implementing the other suggestions from your initial reply and come back with follow ups.