1.3.0 • Published 4 years ago

log4js-elasticsearch-appender v1.3.0

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
4 years ago

Elasticsearch Appender for log4js

Elasticsearch appender for log4js library. This appender pushes logs to Elasticsearch and can be visualized in Kibana. To get started, install the npm package and configure the appender as given below.

There are 4 fields which you must provide to push logs to Elasticsearch, 1. Elasticsearch URL (Eg. https://yourelasticsearchurl.com:9200) 2. Elasticsearch Username (Eg. elasticadmin) 3. Elasticsearch Password (Eg. elasticpassword) 4. Elasticsearch Index Pattern (Eg. myserver-logs)

The appender can be configured like as follows.

`const log4js = require('log4js')

let logConfig = { file: { appenders: { elastic: { type: 'log4js-elasticsearch-appender', elasticIndexPattern: 'Elasticsearch Index Pattern', elasticUrl: 'Elasticsearch URL, elasticUsername: 'Elasticsearch Username', elasticPassword: 'Elasticsearch Password' } }, categories: { default: { appenders: 'elastic' , level: 'debug' } } } }

log4js.configure(logConfig.file)`

Some common questions and places where people go stuck include,

  • Elasticsearch is not by default available via Public IP. Check the yaml settings of your Elasticsearch configuration and also check if Firewall of the Port you're trying to access is opened in your Cloud Provider console (GCP/AWS/Azure or others).
  • Give the full URL including the protocol (http/https) in the elasticUrl field.
  • API Key based authentication is not supported yet, will be updating shortly.

If you need assistance in setting up, please raise an issue in the Github page. I'll try to resolve it for you my spare time.