Skip to content

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 log Caddyfile 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:

txt
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):

txt
(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:

bash
sudo caddy reload --config /etc/caddy/Caddyfile

Step 2: Stream Caddy Access Logs into Logdy ​

Install Logdy (single Go binary, no Node.js, database, or external collector):

bash
brew install logdy
# or: curl https://logdy.dev/install.sh | sh

Option A: Follow Caddy's Access Log File ​

bash
# 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 8080

Option 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:

bash
# 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 8080

Open 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:

bash
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:

json
{
  "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 PathMeaningDebugging Use Case
statusHTTP response status code (200, 404, 502)Click-filter 5xx upstream failures or 4xx spikes
request.hostRequested virtual hostSeparate traffic across multiple domains in one file
request.methodHTTP verb (GET, POST, PUT, DELETE)Isolate mutating API calls during an incident
request.uriPath + query stringTrace requests to a specific endpoint or webhook
durationRequest duration in seconds (float)Spot slow upstream responses
request.client_ipClient IP addressTrack noisy bots, crawlers, or a single test client
levelLog 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:

bash
tail -F /var/log/caddy/access.log \
  | jq -c --unbuffered 'select(.request.uri != "/healthz")' \
  | logdy --port 8080

Logdy vs GoAccess vs jq for Caddy Logs ​

ToolBest ForLive Browser UI?Aggregate Traffic Charts?Line-Level Request Inspection?
LogdyLive incident debugging, inspecting headers/URIs/errorsYesNoYes (full JSON drawer + facets)
GoAccessTraffic analytics (top URLs, bandwidth, GeoIP, status counts)Yes (HTML report / WS)YesLimited (aggregate focus)
jq + tail -FQuick one-off CLI filtering over SSHNo (terminal)NoYes (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,000 lines in memory by default (--max-message-count). Keep Caddy's roll_size / roll_keep configured 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 on logger (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