Logging
Structured logs for Node, Bun, Workers, and the browser.
Node / Bun
- ★ pino — fastest JSON logger; the default for new Node services. Pairs with
pino-pretty(dev) and any log shipper (production). - Winston — older incumbent; transports for everything; bigger surface area than pino.
- bunyan — older still; pino is its spiritual successor.
- consola (UnJS) — gorgeous CLI output; used by Nuxt / Nitro. Great for tools / CLIs; less for production services.
- debug — namespaced
DEBUG=app:* node x.jsstyle; tiny; useful in libraries. - signale — pretty CLI logger.
@logtape/logtape— modern structured logger; Node/Bun/Workers.
Edge / Workers
- ★
@logtape/logtape— works on Workers, Deno, Bun, Node. - ★ Workers built-in
console— stream to Workers Logs / Logpush. - pino with
transport.target: 'pino/file'and an external shipper, orpino-cloudwatchfamily.
Browser logging
- console — fine for most needs.
- loglevel — minimal browser-friendly logger.
- debug — works in the browser too (
localStorage.debug = 'app:*'). - Sentry ships breadcrumbs and console captures automatically; see Observability.
Patterns to know
- Always JSON in production — pretty-print in dev only.
- Correlation IDs — propagate
traceparent(W3C Trace Context) so logs from one request all share an ID. - Levels —
trace / debug / info / warn / error / fatal. Default toinfoin prod. - Don't log secrets — never log full tokens, full request bodies of auth flows, full DB rows with PII.
- Sample high-volume logs — pino has
levelper route; or sample 1% in prod. - Pair with OpenTelemetry — see Observability for traces/metrics that pair with logs.
Log shippers / where logs go
- Better Stack, Axiom, Datadog, Honeycomb, OpenObserve, Grafana Loki, Cloudflare Logpush — see Observability.
- Vercel Log Drains — push Vercel logs anywhere.
pino-axiom,pino-better-stack,pino-datadog— pino transports.
Pick this if…
- Default Node / Bun service: pino.
- Edge / Workers: Workers
console+ Logpush, or@logtape/logtape. - You're writing a CLI: consola.
- Library code: debug.
- Browser: native
console+ Sentry breadcrumbs.