🛠️
Utility10M+/wkMIT

winston

Winston is the most popular logging library for Node.js, designed to be a simple and universal logging framework with support for multiple transports. A transpo

Installation

npm
npm install winston
yarn
yarn add winston
pnpm
pnpm add winston

Import

ESM
import winston from 'winston';

Quick Example

usage
import winston from 'winston';

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.json(),
  transports: [
    new winston.transports.File({ filename: 'error.log', level: 'error' }),
    new winston.transports.Console({ format: winston.format.simple() }),
  ],
});

logger.info('Server started', { port: 3000 });

About winston

Winston is the most popular logging library for Node.js, designed to be a simple and universal logging framework with support for multiple transports. A transport in Winston is a storage device for logs — the library includes built-in transports for console output, files (with rotation), HTTP endpoints, and streams, with community transports available for databases, cloud services, syslog, and more. Winston supports configurable log levels (error, warn, info, http, verbose, debug, silly by default), structured JSON logging, custom formatting through a composable format pipeline, and metadata attachment to log entries. The format system uses combine, timestamp, printf, colorize, json, and other formatters that can be chained together to produce exactly the output format needed. Winston handles multiple simultaneous transports with different log levels — for example, logging errors to a file while showing all levels in the console. The library supports child loggers that inherit configuration with additional default metadata, exception and rejection handling, and profiling. Winston is particularly well-suited for production applications that need flexible log routing and formatting across different environments.

Quick Facts

Packagewinston
CategoryUtility
Weekly Downloads10M+
LicenseMIT
Installnpm install winston

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.