Registry / observability / express-winston-2

express-winston-2

JSON →
library0.0.2jsnpmunverified

Logging middleware for Express.js using winston. Version 0.0.2 (latest). Provides request and error logging with whitelist support for request/response properties, custom log levels based on status code, and skip/ignore functionality. Differentiator: uses winston's flexible transport system and allows fine-grained control over log level via a callback function. Basic functionality, rarely updated.

npm install express-winston-2
INSTALL
IMPORT
SIG · EXPRESS-WINSTON-2
E
express-winston-2
observabilityjavascriptv0.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

expressWinston
const expressWinston = require('express-winston-2');
import expressWinston from 'express-winston-2';
Package does not support ESM. Must use require().
logger
expressWinston.logger(options)
expressWinston.Logger(options)
logger is a method, not a constructor. Case-sensitive.
errorLogger
expressWinston.errorLogger(options)
expressWinston.errorlogger(options)
errorLogger method name is camelCase.

Shows how to set up express-winston-2 middleware with console transport and custom message format.

const winston = require('winston'); const expressWinston = require('express-winston-2'); const express = require('express'); const app = express(); app.use(expressWinston.logger({ transports: [ new winston.transports.Console({ json: true, colorize: true }) ], meta: true, msg: 'HTTP {{req.method}} {{req.url}}', expressFormat: true, colorStatus: true, ignoreRoute: function (req, res) { return false; } })); app.use(require('./my-router')); const port = process.env.PORT || 3000; app.listen(port, () => console.log('Server started'));
Debug
Known issues
gotchaPackage is not ESM compatible; using import syntax will fail.
fix
Use require() instead of import.
affects: >=0.0.0
gotchaThe logger middleware must be placed after the router and before custom error handlers for proper error logging.
fix
Order middleware as: router, expressWinston.logger, expressWinston.errorLogger, error handlers.
affects: >=0.0.0
deprecatedThe whitelist feature is marked as new in 0.2.x but may be removed in future versions.
fix
Check changelog before upgrading; consider alternatives like express-winston.
affects: >=0.2.0
gotchaSetting winstonInstance ignores the transports option; only one should be used.
fix
Use either transports or winstonInstance, not both.
affects: >=0.0.0
gotchaThe getLogLevel function receives the response status code, not the response object.
fix
Define getLogLevel with parameter (statusCode) to return log level.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'express-winston-2'
Package not installed or typo in module name.
fix
Run 'npm install express-winston-2' and check spelling in require().
TypeError: expressWinston.logger is not a function
Incorrect import or module load failure.
fix
Ensure required correctly: const expressWinston = require('express-winston-2');
Error: Invalid winston transport
Transport object is not an instance of winston.Transport.
fix
Use 'new winston.transports.Console()' or appropriate transport constructor.
TypeError: Cannot read property 'statusCode' of undefined
getLogLevel function expects statusCode argument but response object is passed.
fix
Change getLogLine to getLogLevel and accept (statusCode) instead of (res).
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies
winstonrequiredPeer dependency; express-winston-2 directly depends on winston for logging transports and instances.
Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
3
Resources
express-winston-2 — npm install express-winston-2 · libregistry