node-es-logger v0.3.0
This module creates a bunyan logger instance with an output stream bound to elasticsearch instance with logstash compatible JSON format.
Options
- name (required): Bunyan log name
- host: Elasticsearch host. Defaults to
localhost:9200
- type: String or function, Elasticsearch
type
for log entry to be stored under - client: Elasticsearch client. See elasticsearch-js for more details. Useful when custom client options are needed, like setting the Elasticsearch client log level. When used,
host
is ignored - indexPattern: Pattern used to generate index name. See momentjs for more details. Defaults to
[logstash-]YYYY.MM.DD
- index: String or function, Elasticsearch index to store log entry under. When used,
indexPattern
is ignored - serializers: Array of objects, bunyan serializers. See node-bunyan for more details. Defaults to standard serializers
- quiet: Boolean, whether to add the stdout stream to the logger
Minimal Example
var logger = ; logger;
This prints a JSON and also send it to elasticsearch instance at localhost:9200
.
type
from function
Example with var logger = ; logger;
bonsai.io.
Use withvar logger = ; logger;
This prints a JSON and also send it to bonsai's elasticsearch instance at myapp-name-123456789.us-west-2.bonsai.io
.
see bunyan's README for what interfaces the logger
has.