I am using 'morgan' library to log my request, time it takes and the size of response.
But, for a POST request is there a way I can log the POST request and its body size when it is received?
Here is the working sample code snippet you need to add to your app.js
:
morgan.token('body', (req, res) => JSON.stringify(req.body));
app.use(morgan(':method :url :status :response-time ms - :res[content-length] :body - :req[content-length]'));