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 install winston
yarn add winston
pnpm add winston
Import
import winston from 'winston';
Quick Example
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
| Package | winston |
| Category | Utility |
| Weekly Downloads | 10M+ |
| License | MIT |
| Install | npm install winston |
Related Packages
Pino is an extremely fast Node.js logger that outputs newline-delimited JSON (NDJSON) with minimal o…
Morgan is an HTTP request logger middleware for Node.js that records incoming request details in a c…
debug is a tiny JavaScript debugging utility modeled after Node.js core's debugging technique, provi…
Chalk is the most popular library for styling terminal string output with colors and formatting in N…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.