1.0.4 • Published 5 years ago

breeze-eslogger v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

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

ParamDescriptionDefault Value
consoletrueboolean value to disable console logs
filetrueboolean value to disable file logs
elastictrueboolean value to disable elastic logs
es_hosthttp://localhost:9200elastic host.
es_indexrequestlogs-hostnameindex name to store logs in elastic.
filenameaccesslog.logpath/filename for the log file

Docker

check the docker-compose.yml file in the repository for grafana dashboards and elastic setup.