Skip to content

Latest commit

 

History

History
62 lines (41 loc) · 1.25 KB

README.md

File metadata and controls

62 lines (41 loc) · 1.25 KB

Step by Step Guideline

Objective

  • logging activity in node app.
  • Create specific log file every hour
  • Easy configure log file round (Hourly, daily)
  • Easy configure log file size
  • Delete log files after specific days
  • Environment specific log structure

Run application

Clone the repository

git clone https://github.com/bmshamsnahid/Manage-Node-App-Environment

Install dependencies

npm i

Import the logger.js file in your desired place, in my case example.js and invoke it.

const logger = require('./logger');
logger.info('Info log example');

Now run example.js

node example.js

Stream

To integrate with morgan

const express = require('express');
const morgan = require('morgan');

const logger = require('./logger');
const app = express();

app.use(morgan('tiny', { stream: logger.stream }));

Now morgan will put each route information in log file.

Configure

Go to logger.js file and update configurations.

License

MIT