Morgan :- Morgan is a middleware which will help us to identify the clients who are accessing our application. Basically a logger.
To Use Morgan, We need to follow below steps :-
npm install --save morgan
This will add morgan to json.package file
var morgan = require('morgan');
3> // create a write stream (in append mode)
var accessLogStream = fs.createWriteStream(
path.join(__dirname, 'access.log'), {flags: 'a'}
);
// setup the logger
app.use(morgan('combined', {stream: accessLogStream}));
Note: Make sure you do not plumb above blindly make sure you have every conditions where you need .
Above will automatically create a access.log file to your root once user will access your app.