View Caddy JSON Access Logs Live in a Browser UI β
Caddy v2 emits structured JSON access logs out of the box, which makes them easy for machines to parse but tedious to read with tail -f in a terminal. By streaming Caddy's log file into Logdy (logdy follow /var/log/caddy/access.log) or piping systemd output (journalctl -u caddy -f -o cat | logdy), you get a local browser UI with clickable facets for HTTP status, request.method, request.host, request.uri, and durationβwith zero changes to Caddy's default JSON format.
Definition: Caddy's
logCaddyfile directive enables HTTP access logging for a site block and encodes each request as a structured JSON object by default whenever output is written to a file or non-terminal stream.
Step 1: Enable JSON Access Logging in Your Caddyfile β
In Caddy v2, HTTP access logging is disabled for a site until you add the log directive inside that site block (the global log option only configures Caddy's internal runtime logs, not HTTP access logs).
Per Caddy's official log directive documentation, format json is the default whenever logs are written to a file:
example.com {
log {
output file /var/log/caddy/access.log {
roll_size 50MiB
roll_keep 5
}
format json
}
reverse_proxy localhost:3000
}If you host multiple domains in one Caddyfile, define a reusable snippet so every site logs to the same JSON file (each entry already includes request.host):
(json_access_log) {
log {
output file /var/log/caddy/access.log
format json
}
}
api.example.com {
import json_access_log
reverse_proxy localhost:4000
}
app.example.com {
import json_access_log
reverse_proxy localhost:3000
}Reload Caddy without dropping active connections:
sudo caddy reload --config /etc/caddy/CaddyfileStep 2: Stream Caddy Access Logs into Logdy β
Install Logdy (single Go binary, no Node.js, database, or external collector):
brew install logdy
# or: curl https://logdy.dev/install.sh | shOption A: Follow Caddy's Access Log File β
# Stream new requests live
logdy follow /var/log/caddy/access.log --port 8080
# Load existing lines from the file first, then keep tailing
logdy follow /var/log/caddy/access.log --full-read --port 8080Option B: Pipe Caddy Running Under systemd or Docker β
If Caddy logs to stderr under systemd or Docker instead of a file, pipe it straight into Logdy's default stdin mode:
# systemd (use -o cat so journald prefixes don't break JSON parsing)
journalctl -u caddy -f -o cat | logdy --port 8080
# Docker / Docker Compose
docker logs -f caddy 2>&1 | logdy --port 8080Open http://127.0.0.1:8080 in your browser. On a remote VPS, keep Logdy bound to 127.0.0.1, add --ui-pass "strong-password", and forward port 8080 over SSH:
ssh -L 8080:127.0.0.1:8080 [email protected]Key Caddy JSON Fields for Filtering & Facets β
A typical Caddy v2 HTTP access log line looks like this:
{
"level": "info",
"ts": 1765027312.4812,
"logger": "http.log.access.log0",
"msg": "handled request",
"request": {
"remote_ip": "203.0.113.10",
"client_ip": "203.0.113.10",
"proto": "HTTP/2.0",
"method": "POST",
"host": "api.example.com",
"uri": "/v1/webhooks/stripe"
},
"bytes_read": 1420,
"user_id": "",
"duration": 0.184291,
"size": 84,
"status": 502,
"resp_headers": {
"Server": ["Caddy"]
}
}In Logdy, auto-generate columns from JSON or promote nested fields into dedicated columns and facets:
| Caddy JSON Path | Meaning | Debugging Use Case |
|---|---|---|
status | HTTP response status code (200, 404, 502) | Click-filter 5xx upstream failures or 4xx spikes |
request.host | Requested virtual host | Separate traffic across multiple domains in one file |
request.method | HTTP verb (GET, POST, PUT, DELETE) | Isolate mutating API calls during an incident |
request.uri | Path + query string | Trace requests to a specific endpoint or webhook |
duration | Request duration in seconds (float) | Spot slow upstream responses |
request.client_ip | Client IP address | Track noisy bots, crawlers, or a single test client |
level | Log severity (info, error) | Separate handled access logs from TLS/proxy errors |
Filtering Noisy Health Checks Before They Hit Logdy β
If /healthz or /metrics floods your access log, either route health checks to a separate Caddy log_name or filter them out with jq before piping into Logdy:
tail -F /var/log/caddy/access.log \
| jq -c --unbuffered 'select(.request.uri != "/healthz")' \
| logdy --port 8080Logdy vs GoAccess vs jq for Caddy Logs β
| Tool | Best For | Live Browser UI? | Aggregate Traffic Charts? | Line-Level Request Inspection? |
|---|---|---|---|---|
| Logdy | Live incident debugging, inspecting headers/URIs/errors | Yes | No | Yes (full JSON drawer + facets) |
| GoAccess | Traffic analytics (top URLs, bandwidth, GeoIP, status counts) | Yes (HTML report / WS) | Yes | Limited (aggregate focus) |
jq + tail -F | Quick one-off CLI filtering over SSH | No (terminal) | No | Yes (manual expressions) |
Honest Limits of Using Logdy with Caddy β
- Not a web analytics dashboard: Logdy does not calculate unique visitors, bandwidth totals, GeoIP maps, or p95 latency charts. Use GoAccess (which supports Caddy's JSON format) or Prometheus metrics for aggregate reporting.
- No long-term retention: Logdy holds the latest
100,000lines in memory by default (--max-message-count). Keep Caddy'sroll_size/roll_keepconfigured on disk for historical logs. - Mixed stdout/stderr lines: When piping
docker logs -f caddy, Caddy's internal startup messages and HTTP access logs share the stream. Filter onlogger(http.log.access...) in Logdy to focus strictly on HTTP traffic.
FAQ β
Why aren't my Caddy HTTP requests showing up in logs? β
Caddy v2 does not write HTTP access logs until you add a log directive inside each site block in your Caddyfile. The global log option only covers Caddy's internal runtime logs.
Do I need to change Caddy's log format to use Logdy? β
No. Caddy's default file output format is already structured JSON (format json), which Logdy parses natively into columns and facets.
Why did I pass -o cat to journalctl -u caddy -f -o cat? β
Without -o cat, journalctl prepends a plain-text timestamp and hostname before Caddy's JSON object, which prevents automatic JSON parsing. -o cat outputs only the raw JSON message field.
Can I inspect Caddy logs from a remote VPS safely? β
Yes. Run Logdy with its default --ui-ip 127.0.0.1 and --ui-pass, then connect via ssh -L 8080:127.0.0.1:8080 user@server rather than exposing Logdy's port publicly.
How do I view both Caddy access logs and my backend app logs together? β
Start Logdy in multi-port socket mode (logdy socket 8123 8124), forward /var/log/caddy/access.log to 8123 (tail -F /var/log/caddy/access.log | logdy forward 8123), and forward your backend app logs to 8124. Both streams appear side by side with origin-port filtering.
Related guides: Nginx Log Parser & Viewer UI Β· Local JSON Log Viewer Β· Self-Hosted Papertrail & Better Stack Alternative
