A simple log appender for log4js that sends the data to logstash by redis.
npm install log4js-logstash-redis --save
In the "input" part of the logstash server conf :
input {
redis {
codec => json
data_type => "list"
key => "YOURKEY"
}
}
Plain javascript
const log4js = require('log4js');
log4js.configure({
appenders: {
logstash_redis: {
type: 'log4js-logstash-redis',
key: 'YOURKEY',
redis: {
host: 'localhost',
port: 6379,
db: 0 // default 0
},
},
},
categories: { default: { appenders: [ 'logstash_redis' ], level: 'debug' }}
});
const logger = log4js.getLogger();
logger.debug('hello hello');