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
npm
npm install winstonpnpm
pnpm add winstonyarn
yarn add winstonMethods
No methods match this filter.
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.
- For example, one may want error logs to be stored in a persistent remote location (like a database), but all logs output to the console or a local file. (https://cdn.jsdelivr.net/gh/winstonjs/winston@latest/README.md)
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.
Report a problem with this API docOpens a pre-filled issue on GitHub.