Winston: Node.js logging library
Winston is the logging library many Node.js developers reach for first because it routes messages to multiple destinations — file, console, any transport — without hand-rolled plumbing. Its API is more verbose than pino's structured-first defaults: createLogger, .add()/.remove() juggling, format.combine() pipelines. That verbosity buys real control: per-transport level filtering, pluggable formats, and runtime reconfiguration via .configure().
What is Winston?
Winston is a Node.js logging library built around one idea: a single logger can write to several destinations at once, each with its own severity threshold and format. You create it with winston.createLogger(), attach transports like Console or File, and route logs through a format.combine() pipeline. Internally, loggers and transports behave as objectMode streams, so each call becomes an info object carrying a level and message.
Core features: transports, levels, and formats
- ✓Multiple transports per logger, each with its own level threshold — Console can get only error-level output while a File transport gets everything from info down.
- ✓winston.createLogger() config accepts level, levels, format, transports, exitOnError, and silent, each with a stated default (level defaults to 'info', format defaults to winston.format.json).
- ✓Log levels follow RFC5424 severity ordering; the built-in npm levels (error, warn, info, http, verbose, debug, silly) are numerically ascending from most to least important.
- ✓Custom log levels and colors via a levels/colors object passed to createLogger and winston.addColors(), which also turns on the colorize() formatter.
- ✓Format pipelines built with format.combine() chain formatters like timestamp(), label(), printf(), json(), and prettyPrint() from the separate logform package.
- ✓Child loggers via logger.child() attach metadata overrides to every message a child emits, without touching the parent logger's transports.
- ✓Runtime transport management: logger.add(), .remove(), and .clear() change where logs go after the logger already exists, and .configure() replaces the whole transport set wholesale.
Setting up your first Winston logger
Start with winston.createLogger() and a config object: set level (e.g. 'info'), a format (e.g. winston.format.json()), and a transports array. A common pattern sends only error-level output to a dedicated File transport writing error.log, sends info-and-above to a second File transport writing combined.log, then conditionally adds a Console transport when process.env.NODE_ENV isn't 'production' so local development still gets readable console output. From there, logger.info(), logger.warn(), and the other level methods are available directly on the returned logger.
When to use Winston
- •An Express or Node API that needs error logs in a persistent file while still printing readable output to the console in development.
- •A service where different log levels need different destinations, e.g. syslog-style severities routed to different transports by level threshold.
- •A codebase standardizing metadata on every log line, using defaultMeta or logger.child() to stamp messages with a service name or request ID.
- •A team that wants to swap logging destinations later without rewriting call sites — logger.info() stays the same even if the transport changes.
Strengths
- ✓Per-transport level thresholds mean a single createLogger() call can quietly log everything to a file while only surfacing errors on the console — no second logging codepath needed.
- ✓Logger and Transport instances are just objectMode streams under the hood, so a custom transport means implementing a standard Node stream interface instead of a Winston-specific plugin API.
- ✓Custom log levels and colors are first-class: pass your own levels object to createLogger() and call winston.addColors(), rather than hacking around a fixed severity list.
- ✓Reconfiguring a live logger doesn't require rebuilding it — .add(), .remove(), and .configure() change transports on an instance that's already in use.
Winston limitations and known gotchas
- △The default logger exported by require('winston') ships with zero transports; logging through it before adding one silently goes nowhere, and the README itself warns that leaving it without transports can cause high memory usage.
- △logger.child() is explicitly flagged in the README as likely buggy when you extend the Logger class, because the this keyword stops pointing at what you'd expect — a real gotcha, not a hypothetical one.
- △createLogger()'s six parameters (level, levels, format, transports, exitOnError, silent), plus the separate format-combine pipeline, is more to learn than a single structured-logging call in a newer library.
- △No performance numbers or throughput benchmarks are documented, so there's nothing here to size Winston against a high-throughput service ahead of testing it yourself.
Alternatives: Winston vs pino vs bunyan
Frequently asked questions about Winston
Call winston.createLogger() with a config object — level, format, and a transports array. A minimal example sets level: 'info', format: winston.format.json(), and transports: [new winston.transports.Console()], then calls logger.info() or logger.log() to write a message.
Winston ships core transports including Console and File, both built on Node's core networking and file I/O. Community members maintain additional transports beyond that, such as winston-daily-rotate-file for date-based log rotation, which Winston's own docs reference directly.
Winston supports custom log levels — pass your own levels object to winston.createLogger() instead of the default npm levels (error, warn, info, http, verbose, debug, silly), then call winston.addColors() if you also want each custom level color-coded in output.
Install Winston as a dependency, then replace scattered console.log calls with a single shared logger created via winston.createLogger(), typically in its own module you import wherever logging is needed. Attach a File transport for persistence and a Console transport for local development, gated behind NODE_ENV.
The default logger exposed by require('winston') has no transports attached out of the box, so calling winston.info() on it silently does nothing until you add one with winston.add(). Winston's own docs warn that leaving it without transports can also lead to high memory usage.
Winston's design — per-transport level filtering, pluggable formats, and objectMode stream internals — targets exactly the multi-destination logging production services need. Its documentation doesn't publish throughput benchmarks, though, so validate it under your own load and account for the documented default-logger and logger.child() gotchas before shipping it at scale.
The problem it solves
Node's console.log gives you one destination and no severity model — every message looks the same and lands on stdout. console.log doesn't model severity at all. The moment a service needs error logs to persist in a file while routine info logs stay ephemeral on the console, or needs different verbosity per environment, that becomes hand-rolled plumbing unless something already treats 'where does this log go' and 'how important is it' as separate, per-destination concerns. Winston makes exactly that split configurable per transport, which is the specific gap it fills.
How to install / try
The README doesn't show an explicit npm install command, but every usage example requires the package as const winston = require('winston'), which is only possible after installing the winston package from npm into a Node.js project — so npm install winston is the standard path even though it isn't spelled out verbatim in the docs.
Who should try it — and who should skip
Reach for Winston if your Node.js service already needs more than one log destination — file plus console, or different severities routed differently — and you're fine writing a bit more setup code for that control. Skip it if you just want structured JSON out of the box with minimal config: pino's defaults get you there with less to declare. Teams extending Winston's Logger class via inheritance should budget time for the documented .child() quirk before relying on it.
Related repositories
Is winston worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of winston.
