pino

Super-fast, low-overhead JSON logger for Node.js — structured logs with transports, redaction, and child loggers.

pino

Node.js

Super-fast, low-overhead JSON logger for Node.js — structured logs with transports, redaction, and child loggers.

Fit

Bundle (gzip)

3.4 kB

8.5 kB raw

Install size includes transitive dependencies. Bundle size is gzipped browser payload.

Freshness

The Problem

console.log produces unstructured output that's hard to search and filter in log aggregation tools. Most logging libraries serialize objects synchronously, adding latency to every request.

What It Does

Pino serializes logs to JSON asynchronously via a worker thread, minimizing the impact on your hot path. Every log entry includes a timestamp, level, and any metadata you pass. Child loggers propagate context (like request ID) to all logs within a scope without repeating it.

Installation

bash
npm install pino pino-pretty

Usage Example

typescript
import pino from 'pino';

const logger = pino({
  level: process.env.LOG_LEVEL ?? 'info',
  redact: ['req.headers.authorization', 'user.password'],
});

// Child logger with request context
const reqLogger = logger.child({ requestId: 'abc-123', method: 'GET', path: '/users' });

reqLogger.info('Fetching users');
reqLogger.error({ err }, 'Database query failed');

Related packages