A simple log appender for log4js that sends the data to logstash by kafka.
npm install log4js-logstash-kafka --save
In the "input" part of the logstash server conf :
input {
kafka {
topic_id => "YOURTOPIC"
codec => json
}
}
Plain javascript
const log4js = require('log4js');
log4js.configure({
appenders: [{
type: "log4js-logstash-kafka",
topic: "YOURTOPIC"
}]
});
const logger = log4js.getLogger();
logger.debug('hello');