1.1.0 • Published 7 years ago

elasticsearch-logger v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Elasticsearch Logger for Node.js

Build Status npm version GitHub license

A configuration-free Elasticsearch logger for node.js with sane defaults.

Usage

Check out the example here.

const logger = require('elasticsearch-logger')();

try {
  throw new Error('An error has occurred.');
} catch (e) {
  logger
    .error(e)
    .then(() => console.error(e));
}

Options

elasticsearch-logger accepts an optional options parameter during creation.

Example

const createLogger = require('elasticsearch-logger');

const logger = createLogger(options?: Object)
ParamTypeDefaultDescription
hostsarray or stringlocalhost:9200The names of elasticsearch hosts.
hoststringlocalhost:9200The name of the elasticsearch host.
applicationstringprocess.env.npm_package_nameapplication name added to log payload.
environmentstringprocess.env.NODE_ENV or localenvironment name added to log payload.
indexstringloggerElasticsearch index name for logger.

Requirements

  • Node.js 6+
  • Elasticsearch