0
我在AWS后面运行Elastic Load Balancer中的node.js express应用程序。我使用'摩根'作为我的记录机制。快速摩根日志记录无法跳过日志记录保持活动请求
ELB定期发送一个保持活动的请求,它的目标是我定义为1个字符文本文件(keep-alive.txt)。
显然,我不想在日志中看到这些请求,所以我使用了摩根跳过功能如下:
// use morgan to log requests to the console
var morganOptions = {
skip: function (req, res) {
return req.get('/keep-alive.txt'); // don't log the load balancer keep alive pings
}
};
app.use(logger('dev', morganOptions));
按照morgan doc,返回TRUE以跳过功能应该引起日志跳过。然而,摩根正在记录每个保持活动的提取。我究竟做错了什么?
完美地工作。太感谢了! – RustyB
将我的评论发布为答案,以便您可以选择它。 – arboreal84