Stores log events in a Redis database. Plugin for log4js > 2.x
npm install @log4js-node/redistype-redishost-string(optional, defaults to127.0.0.1) - the location of the redis serverport-integer(optional, defaults to6379) - the port the redis server is listening onpass-string(optional) - password to use when authenticating connection to redislayout-object(optional, defaults tomessagePassThroughLayout) - the layout to use for log events (see layouts).channel-string- (required if nolistspecified) the redis channel that log events will be published tolist-string- (required if nochannelspecified) the redis list that log events will be inserted to
The appender will use the Redis PUBLISH command to send the log event messages to the channel. Otherwise the appender will use the Redis RPUSH command to send the log event messages to the list.
- Pub
log4js.configure({
appenders: {
redis: { type: '@log4js-node/redis', channel: 'logs' }
},
categories: { default: { appenders: ['redis'], level: 'info' } }
});This configuration will publish log messages to the logs channel on 127.0.0.1:6379.
- List
log4js.configure({
appenders: {
redis: { type: '@log4js-node/redis', list: 'someLogList' }
},
categories: { default: { appenders: ['redis'], level: 'info' } }
});This configuration will insert log messages to the someLogList list on 127.0.0.1:6379.