log4js-rediskey-appender
v1.0.1
Published
Redis Key Appender for log4js
Downloads
2
Readme
Redis Key Appender for log4js-node
Plugin for log4js
Store log events in a Redis database with key and value.
This appender is using RPUSH of redis command to store key value pair.
Installation
Install with npm
npm install log4js
npm i log4js-rediskey-appender
Configuration
type
-redis
host
-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 rediskey
-string
(optional) - key will be used to save logs in redis, if keys is not provided then current date will consider as key in format ofYYYY_MM_DD
prefix
-string
(optional) - prefix will be append with provide keyttl
-string
(optional) - seconds to expire keyredis_url
-string
(optional) - exampleredis://myuser:[email protected]:6379)
if provided, then ignore host, port and pass configuration
Example
log4js.configure({
appenders: {
redis: {
type: 'log4js-rediskey-appender',
prefix: 'myprefix',
ttl: 604800, //7 Days
redis_url: 'redis://myuser:[email protected]:6379'
}
},
categories: { default: { appenders: ['redis'], level: 'debug' } }
});
This configuration will append message using RPUSH with key logs_myprefix_2024_05_18
on 127.0.0.1:6379
.