log4js-elasticsearch-appender

1.3.0 • Public • Published

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.

Package Sidebar

Install

npm i log4js-elasticsearch-appender

Weekly Downloads

6

Version

1.3.0

License

GPL-3.0

Unpacked Size

3.49 kB

Total Files

3

Last publish

Collaborators

  • praveent
  • praveentcom