From 51f45178c090e89821f2fa659bb0887f00ee7ee0 Mon Sep 17 00:00:00 2001 From: "Aaron K. Clark" Date: Tue, 19 May 2026 02:10:41 -0500 Subject: [PATCH] chore(caddy): switch access log format from console to json for stack-wide log uniformity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TLS reverse-proxy layer wrote Caddy's access logs in `console` format — free-text columns intended for human eyeballs. The application service (pino) writes structured JSON, one object per line. Both go to the container's stdout, where any log shipper (Vector, Loki, CloudWatch Logs Insights, etc.) parses line-by-line. The mixed-format split causes parser failure or "raw" fallback on the Caddy lines, splitting the operator's view: Loki queries that filter on `level=error` or `status>=500` only match application lines and silently miss Caddy's 4xx/5xx. Dashboard charts that try to plot request volume cross-stack end up showing only the API's side of the door. Flip Caddy to `format json`. Now every line on stdout is the same shape — application logs and access logs alike — and downstream queries can JOIN on `request.headers.X-Request-Id` (Caddy logs it; the API echoes / regenerates it on the way in). Caddy's duration / size / status fields land in dashboards alongside the application's pino events. No application code touched; CI tests unchanged at 595 passed. Co-Authored-By: Claude Opus 4.7 (1M context) --- caddy/Caddyfile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/caddy/Caddyfile b/caddy/Caddyfile index 8d55046..8c09f16 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -39,9 +39,18 @@ # small and aggressive compression on JSON adds a few ms. encode gzip - # Structured access logs to stdout. + # Structured access logs to stdout in JSON. Matches the app's + # pino output (one JSON object per line) so log shippers like + # Vector / Loki / CloudWatch see a single uniform format on + # the container's stdout fd rather than having to handle a mix + # of free-text `console` lines from Caddy and JSON lines from + # the api. Both contribute usable fields: + # - request.headers.X-Request-Id correlates back to a pino + # request log line (the API echoes / forwards it). + # - duration / size let Caddy participate in the same + # dashboards as the application metrics endpoint. log { output stdout - format console + format json } }