Capture Structured Logs and Pipe to jq

logs & debug

// what it does

Switches from the interactive pretty view to newline-delimited JSON so you can grep, transform, or archive logs. Pipe it through `jq` to slice on fields like `outcome`, or redirect to a file for later analysis. This is how you turn a live stream into something machine-readable.

// shell

$ wrangler tail --format json | jq 'select(.outcome=="exception")'
$ wrangler tail --format json --sampling-rate 0.05 > tail.log

// gotcha

On a high-traffic Worker the stream floods and tail gets rate-limited — add `--sampling-rate 0.05` (a fraction from 0 to 1, so 5% here) to stay connected, accepting that you'll miss most events.