log4js-elasticsearch-appender
Version:
Elasticsearch appender for log4js library. This appender pushes logs to Elasticsearch and can be visualized in Kibana.
30 lines (27 loc) • 700 B
JavaScript
const { Client } = require('@elastic/elasticsearch')
let client;
let sendMessage = (config, loggingEvent) => {
client.index({
index: config.elasticIndexPattern,
body: {
log: loggingEvent
}
})
}
function configure(config) {
return hangoutAppender(config);
}
function hangoutAppender(config) {
client = new Client({
node: config.elasticUrl,
auth: {
username: config.elasticUsername,
password: config.elasticPassword
}
})
const appender = (loggingEvent) => {
sendMessage(config, loggingEvent);
};
return appender;
}
exports.configure = configure;