API Reference

Winston

Versatile logging library for Node.js with multiple transports, levels, and formats.

Official Documentation ↗
CompatibilityThis documentation covers version v3.17. Check the official docs for the latest API surface.

Installation

npmnpm install winston
pnpmpnpm add winston
yarnyarn add winston

Methods

Winston is a multi-transport async logging library for Node.js. It is designed to be a simple and universal logging tool with support for multiple transports, log levels, formats, and metadata.

Key Features

  • Multiple transports: Console, File, Http, Stream, and custom
  • Log levels: Configurable hierarchies and filtering
  • Formats: JSON, printf, colorize, timestamp, combine
  • Child loggers: Bind persistent metadata per request
  • Streaming: Query and stream logs for analysis

Errors

The following points are quoted verbatim from the official documentation. 来源:https://cdn.jsdelivr.net/gh/winstonjs/winston@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:53:30.407Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

FAQ

What are transports in Winston?
Transports are output destinations for log entries, such as Console, File, Http, or Stream. You can add multiple transports to a logger to fan out logs to several sinks with independent formats and levels.
How do I log JSON with Winston?
Use winston.format.json() in the logger format, optionally combined with timestamp and errors. Each log call accepts a metadata object that is merged into the JSON output.
How does Winston handle log levels?
Winston supports configurable levels with severity ordering. By default it uses npm levels (error, warn, info, verbose, debug, silly). A logger only emits entries at or above its configured level.