Hi @tharindurewatha ,
you can achieve this by specifying skip function:
// EXAMPLE: only log error responses morgan('combined', { skip: function (req, res) { return res.statusCode < 400 } })
and in this function you just check:
req.method
property to satisfy your condition.
@nempet thanks for replying to this comment. I am barely getting back to articles.
I also found a similar example with a bit more specificity from your own docs:
app.use(morgan({ collection: 'error_logger', connectionString: 'mongodb://localhost:27017/logs-db', user: 'admin', pass: 'test12345' }, { skip: function (req, res) { return res.statusCode < 400; } }, 'dev' ));
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi @tharindurewatha ,
you can achieve this by specifying skip function:
and in this function you just check:
property to satisfy your condition.
@nempet thanks for replying to this comment. I am barely getting back to articles.
I also found a similar example with a bit more specificity from your own docs: