Reputation: 63
I have searched through the docs and threads but can't seem to find a way to configure Morgan to skip logging based on response times. I would like to do something like the following, but can figure out how to get the response time that Morgan already calculates. Any help would be appreciated.
app.use(morgan("common", {
skip: function(req, res) {
if(res.statusCode > 400 || res.respondTime > 200){
return false;
}else{
return true;
}
}));
Upvotes: 0
Views: 77
Reputation: 63
I found what I needed from this article. It doesn't utilize Morgan, but the results are very similar and perfect for what I need.
https://ipirozhenko.com/blog/measuring-requests-duration-nodejs-express/
Upvotes: 0