Registry / observability / winston-express-middleware

winston-express-middleware

JSON →
library0.1.0jsnpmunverified

Express.js middleware for request and error logging using winston. Version 0.1.0 (stable, but low release cadence). Supports whitelisting of request/response properties, custom log levels per status code, and multiple transports. A fork of express-winston with updated whitelisting and winston compatibility. Limited to Node >=0.6.0; no TypeScript definitions. Not actively maintained.

npm install winston-express-middleware
INSTALL
IMPORT
SIG · WINSTON-EXPRESS-MI
W
winston-express-middleware
observabilityjavascriptv0.1.0
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
import expressWinston from 'winston-express-middleware'
const expressWinston = require('winston-express-middleware').default
Default export via ESM. CommonJS require yields the module directly.
logger
import { logger } from 'winston-express-middleware'
const logger = require('winston-express-middleware').logger
Named export for the request logging middleware.
errorLogger
import { errorLogger } from 'winston-express-middleware'
const errorLogger = require('winston-express-middleware').errorLogger
Named export for the error logging middleware.

Shows basic setup with request and error logging middleware, using Console transport with JSON and colorization.

const winston = require('winston'); const expressWinston = require('winston-express-middleware'); const express = require('express'); const app = express(); // Request logging 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 })); app.get('/', (req, res) => res.send('Hello')); // Error logging (after routes) app.use(expressWinston.errorLogger({ transports: [new winston.transports.Console({ json: true, colorize: true })] })); app.use((err, req, res, next) => { res.status(500).send('Error'); }); app.listen(3000);
Debug
Known issues
gotchaMust be placed after router but before custom error handlers for error logging to work.
fix
Order middleware as: app.use(router), app.use(errorLogger), then your error handler.
affects: >=0.1.0
deprecatedWinston v1 is deprecated; this middleware is not updated for winston v2+.
fix
Use a maintained fork like 'express-winston' (available on npm) or update manually.
affects: >=0.1.0
gotchaThe 'transports' option is ignored if 'winstonInstance' is provided.
fix
Use either 'transports' or 'winstonInstance', not both.
affects: >=0.1.0
gotcha'expressFormat' overrides 'msg' and 'colorStatus' when true.
fix
Set 'expressFormat: false' to use custom 'msg' and 'colorStatus'.
affects: >=0.1.0
gotchaThe 'skip' option expects a function that returns boolean; default is false (never skip).
fix
Provide a function like (req, res) => res.statusCode < 400 to skip non-errors.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'winston-express-middleware'
Package not installed.
fix
Run 'npm install winston-express-middleware' in your project directory.
TypeError: expressWinston.logger is not a function
Incorrect import style (e.g., destructuring non-existent export).
fix
Use 'const expressWinston = require('winston-express-middleware')' and then 'expressWinston.logger(...)'.
Error: winston.transports.Console is not a constructor
Using winston v2+ API with older transport pattern.
fix
Ensure winston version 1.0.x is installed: 'npm install winston@1.0.x'.
Warning: options.transports is deprecated, use winstonInstance
Mixed API usage; both options provided.
fix
Remove 'transports' if using 'winstonInstance', or vice versa.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
winstonrequiredCore logging library; must be installed separately as peer dependency (v1.0.x required)
Agent activity
38 hits · last 30 days
node
30
OpenAI (training)
1
Resources
winston-express-middleware — npm install winston-express-middleware · libregistry