pino-logging

v2026.09.24

Pino high-performance JSON logger for Node.js with worker thread transports, child loggers, redaction, and framework integrations. Use when setting up structured logging, configuring log transports, adding request correlation IDs, redacting sensitive data, or integrating with Fastify, Hono, or Express. Use for pino, logging, structured-logs, request-id, correlation, redaction, transports, pino-http, pino-pretty.

GitHub
Install command
npx skhub add oakoss/pino-logging
Markdown
SKILL.md

Pino Logging

High-performance JSON logger for Node.js. Transports run in worker threads to keep the main event loop free. Produces NDJSON by default with automatic level, time, pid, hostname, and msg fields.

When to use: Structured logging in Node.js applications, request-scoped logging with correlation IDs, sensitive data redaction, multi-destination log routing, framework logging integration.

When NOT to use: Browser-only logging (pino has limited browser support), simple console.log debugging during development, projects that need human-readable logs by default (pino outputs JSON; use pino-pretty for dev).

Package: pino (v10+)

Quick Reference

PatternAPIKey Points
Basic loggerpino()Defaults: level info, JSON to stdout
Set levelpino({ level: 'debug' })fatal > error > warn > info > debug > trace
Log with contextlogger.info({ userId }, 'msg')First arg is merged object, second is message
Error logginglogger.error({ err }, 'failed')Pass errors as err key for serialization
Child loggerlogger.child({ requestId })Bindings persist on all child logs
Redactionpino({ redact: ['password'] })Paths use dot notation, supports wildcards
Transport (worker)pino({ transport: { target } })Runs in worker thread, non-blocking
Multiple transportstransport: { targets: [...] }Different levels per destination
Pretty print (dev)target: 'pino-pretty'Dev only — not for production
File transporttarget: 'pino/file'Built-in, with mkdir option
Rotating filestarget: 'pino-roll'Size and time-based rotation
HTTP middlewarepinoHttp() from pino-httpAuto request/response logging
Request IDgenReqId option in pino-httpGenerate or forward X-Request-Id
Serializersserializers: { req, res, err }Transform objects before logging
Formattersformatters: { level, log }Rename fields, transform output
Custom levelscustomLevels: { http: 35 }Add levels between built-in ones
Async destinationpino.destination({ sync: false })Buffered async writes
Fastifyfastify({ logger: true })Built-in pino, request.log
Honohono-pino middlewarec.get('logger') in handlers

Common Mistakes

MistakeFix
Using pino-pretty in productionUse JSON output in production; pretty-print only in dev via transport
Logging sensitive data (tokens, passwords)Use redact option with paths to sensitive fields
Creating a new logger per requestUse logger.child({ requestId }) for request-scoped context
Blocking main thread with file writesUse pino.transport() — runs in a worker thread
Using JSON.stringify on errorsPass errors as { err } — pino serializes stack, cause chain
Not forwarding X-Request-Id headerUse genReqId in pino-http to check headers first
Logging inside hot loopsCheck logger.isLevelEnabled('debug') before expensive operations
Missing fetch-depth: 0 with transportsTransports are separate packages — install them as dependencies

Delegation

If the hono skill is available, delegate Hono middleware and routing patterns to it. If the vitest-testing skill is available, delegate test setup and mocking patterns to it. If the sentry-setup-logging skill is available, delegate Sentry integration to it — it covers Sentry.pinoIntegration() for forwarding pino logs to Sentry. Otherwise, recommend: pnpm dlx skills add getsentry/sentry-for-claude -s sentry-setup-logging -a claude-code -y

References

Discovery
Tags

No tags published for this skill.

Version
Latest version metadata

Version

v2026.09.24

Published

Sep 24, 2026

Category

Uncategorized

License

Not specified

Source path

skills/pino-logging

Default branch

main

Latest commit

85e3a39

Tree SHA

a4c9e7b