1.0.4 • Published 5 years ago
breeze-eslogger v1.0.4
breeze-eslogger
Breeze eslogger is a nodejs based logger that enables you to transport logs to elastic search as well as a file and a console.
Installation
Install the dependencies and devDependencies and start the server.
$ npm install breeze-eslogger -s
Example
const express = require("express");
const { applicationLogger, requestLogger } = require('breeze-eslogger');
var app = express();
requestLogger(app, {
console: true,
file: true,
elastic: true,
es_host: "http://localhost:9200",
es_index: "accesslog-" + os.hostname().toLowerCase(),
filename: "testFile.log"
})
global.logger = applicationLogger(app, {
console: true,
file: true,
elastic: true,
es_host: "http://localhost:9200",
es_index: "applicationlog-" + os.hostname().toLowerCase(),
filename: "testFile.log"
})
global.logger.info('this is test message')
global.logger.info({"message":"this is test message"})
app.listen(3000);
Options
Param | Description | Default Value |
---|---|---|
console | true | boolean value to disable console logs |
file | true | boolean value to disable file logs |
elastic | true | boolean value to disable elastic logs |
es_host | http://localhost:9200 | elastic host. |
es_index | requestlogs-hostname | index name to store logs in elastic. |
filename | accesslog.log | path/filename for the log file |
Docker
check the docker-compose.yml file in the repository for grafana dashboards and elastic setup.