Winston is a highly flexible and extensible logging library for Node.js, designed to handle logs for various applications and environments. Its current stable version is 3.19.0, with regular patch and minor releases addressing bug fixes, dependency updates, and minor feature enhancements. A key differentiator is its architecture, which decouples the logging process into modular components like transports (storage devices for logs) and formats (for log message presentation). This allows users to configure multiple transports with different logging levels and formatting rules, such as sending errors to a remote database while outputting all logs to a local file or console. Winston also supports custom logging levels and dynamic formatting, providing granular control over how logs are generated and stored, distinguishing it from simpler logging utilities.
npm install winstonVerified import paths — ran on the pinned version, not inferred.
Initializes a Winston logger with file and console transports, demonstrating different log levels, metadata, and conditional configuration for development vs. production environments.
Refer to the `UPGRADE-3.0.md` guide in the Winston GitHub repository when migrating from v2.x. Update `require('winston')` to `winston.createLogger(...)` and adjust format/transport instantiations.Always add at least one transport (e.g., `winston.add(new winston.transports.Console());`) to the default logger if you choose to use it, or preferably, create a custom logger instance with `winston.createLogger()`.
Remove references to `LogCallback` in your TypeScript code. The underlying library did not effectively support these callbacks, and their removal clarifies the API. If async operations are needed, use promises or async/await patterns.
Configure custom levels using the `levels` option in `createLogger()` and ensure your formats and transports are aware of these custom levels. Example: `levels: { fatal: 0, error: 1, ... }`.Ensure you have `winston@^3.0.0` installed (`npm install winston@latest`) and are using `import { createLogger } from 'winston'` for ESM, or `const winston = require('winston');` for CJS.Add at least one transport to your logger configuration, for example: `transports: [new winston.transports.Console()]` when calling `createLogger`.
Always import transports and formats from the main 'winston' package: `import { transports, format } from 'winston'; new transports.Console();`Ensure `@types/winston` is installed and up-to-date (`npm install --save-dev @types/winston`). Verify that the `level` property is correctly placed within the `createLogger` options object.
No dependency data recorded yet.