Skip to content

chore(caddy): switch access log format from console to json for stack-wide log uniformity#152

Merged
CryptoJones merged 1 commit into
masterfrom
chore/caddy-json-log-format
May 19, 2026
Merged

chore(caddy): switch access log format from console to json for stack-wide log uniformity#152
CryptoJones merged 1 commit into
masterfrom
chore/caddy-json-log-format

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #151.

Summary

caddy/Caddyfile wrote access logs in console format. The application service (pino) writes structured JSON. Both go to the same container stdout, where log shippers parse line-by-line — the mixed-format split caused parser failure / raw fallback on the Caddy lines and meant queries filtering on level=error / status>=500 silently missed Caddy-level 4xx/5xx.

Flip Caddy to format json. Whole container stdout stream becomes one uniform structured format; cross-layer correlation by X-Request-Id works because Caddy logs the request header and the API echoes the same id back.

Test plan

  • npm run lint — clean
  • npm test — 595 passed, 15 skipped (no application code touched)
  • Caddyfile change is config-only; manual verification on a TLS test deploy would confirm log shape, but the change is the documented Caddy JSON access-log option and reverts cleanly if needed

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

…-wide log uniformity

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) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit c82f019 into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the chore/caddy-json-log-format branch May 19, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

caddy: access logs in console format break log-shipper parsing alongside structured pino output

1 participant