Step by Step Guideline
loggingactivity 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
Clone the repository
git clone https://github.com/bmshamsnahid/Manage-Node-App-EnvironmentInstall dependencies
npm iImport 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.jsTo 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.
Go to logger.js file and update configurations.
MIT