Registry / messaging / winston-redis

winston-redis

JSON →
library3.1.0jsnpmunverified

A capped Redis transport for the winston logging library (v3). Version 3.1.0 is the current stable release, with minimal maintenance updates since 2019. It stores log messages as JSON literals in a fixed-length Redis list, enabling efficient log rotation. Supports channel-based streaming and custom metadata. Requires Node >=8.11.x, winston ^3.0.0, and redis ^2.8.0. Alternatives include winston-logstash-transport or custom transports.

npm install winston-redis
INSTALL
IMPORT
SIG · WINSTON-REDIS
W
winston-redis
messagingjavascriptv3.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

winston-redis
import Transport from 'winston-redis'
import redisTransport from 'winston-redis'
Default export is the Redis transport class, not a named export.
winston-redis (CommonJS)
const redisTransport = require('winston-redis')
const { Redis } = require('winston-redis')
CJS users should require the whole module; it's a constructor.
WinstonRedis Instance
new Transport({ container: 'logs' })
new Transport.Redis()
Instantiate with `new Transport()` directly; no static factories.
TypeScript types
import Transport from 'winston-redis'
import * as Transport from 'winston-redis'
No built-in TypeScript declarations; create own or use `any`.

Shows how to create a winston logger with the winston-redis transport, including Redis host/port from environment variables.

const winston = require('winston'); const Transport = require('winston-redis'); const logger = winston.createLogger({ level: 'info', transports: [ new Transport({ host: process.env.REDIS_HOST || 'localhost', port: process.env.REDIS_PORT || 6379, length: 500, container: 'app-logs' }) ] }); logger.info('Hello from winston-redis');
Debug
Known issues
breakingRequires Node >=8.11.x and winston 3.x only. Not compatible with winston 2.x.
fix
Upgrade to winston 3.x and Node >=8.11.x.
affects: 3.x
deprecatedThe `redis` peer dependency is version 2.x. As of 2021, redis 3.x is LTS, but this transport may not work with it.
fix
Use `redis@2.8.0` explicitly or fork/update transport to support 3.x.
affects: >=3.0.0
gotchaIf you pass an existing redis client via `options.redis`, the transport will not close it on `close()`. This can cause lingering connections.
fix
Manage the redis client lifecycle externally or avoid passing a client.
affects: >=1.0.0
breakingThe transport now returns a promise from `log()` in winston 3.x; ensure error handling is updated.
fix
Use async/await or attach `.catch()` when calling `logger.log()` or `logger[level]()`.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: redis.createClient is not a function
Using redis 3.x which changed `createClient` to be a constructor.
fix
Install redis@2.8.0: `npm install redis@2.8.0`
Error: connect ECONNREFUSED 127.0.0.1:6379
Redis server not running or unreachable at default host:port.
fix
Start Redis server or set `host`/`port` options correctly.
TypeError: winston.createLogger is not a function
Using winston 2.x which does not have `createLogger`.
fix
Upgrade winston to 3.x: `npm install winston@3`
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
winstonrequiredPeer dependency for logger instance
redisrequiredPeer dependency for Redis client (version 2.x)
Agent activity
33 hits · last 30 days
node
30
OpenAI (training)
1
Resources
winston-redis — npm install winston-redis · libregistry