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.

Usage no npm install needed!

<script type="module">
  import breezeEslogger from 'https://cdn.skypack.dev/breeze-eslogger';
</script>

README

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.