This package allows you to do logs

npm install --save morgan

app.js

...
const fs = require('fs');
...

const accessLogStream = fs.createWriteStream(path.join(__dirname, 'access.log'), { flags: 'a' });

app.use(morgan('combined', { stream: accessLogStream }));
...



Advanced logging: https://blog.risingstack.com/node-js-logging-tutorial/