简体   繁体   English

如何在终端中删除/忽略“ mongo-express”节点表示中间件的输出?

[英]How to remove / omit `mongo-express` node express middleware's output in the terminal?

In the browser, when I visit my local installation of the Mongo-Express Web Interface, I see something like this: 在浏览器中,当我访问Mongo-Express Web Interface的本地安装时,会看到以下内容:

在此处输入图片说明

In the console however, it prints out every resources requests used on the page (images, css, scripts, etc.) 但是,在控制台中,它会打印出页面上使用的每个资源请求(图像,css,脚本等)。

在此处输入图片说明

Is there anyway to turn-off or omit this? 是否有关闭忽略此功能?

I've tried digging into the mongo-express config file for a way to disable the output, but no dice. 我尝试过挖掘mongo-express配置文件以禁用输出,但没有骰子。

Note: In case it helps, I'm using it in my NodeJS express app like so: 注意:如果有帮助,我可以在NodeJS Express应用程序中使用它,如下所示:

app.use('/mongo-express', mongo_express(mongoConfig));

My guess is that I'd have to change something in the mongoConfig JS file (it's obtained via a require(...) call somewhere higher in the code), or start the mongod service with some sort of 我的猜测是,我必须更改mongoConfig JS文件中的mongoConfig (可以通过代码中较高位置的require(...)调用获得),或使用某种方式启动mongod服务
--quiet flag ( but to me, that sounds like it has nothing to do with controlling the output in express's middleware, since mongo-express != mongod service ). --quiet标志( 但是对我来说,这听起来与控制express中间件中的输出无关,因为mongo-express != mongod service )。

Even though this question is quite old, I just stepped over it. 即使这个问题已经很老了,我还是跳过了它。

Find the entry 查找条目

logger: {}

in the config-file near the end and change it to 在最后的配置文件中并将其更改为

logger: {
    skip: function(req, res) {return true;}
}

This tells the morgan-logger to skip all output. 这告诉morgan-logger跳过所有输出。 With this function you can control what is logged based on the request or response object. 使用此功能,您可以控制基于请求或响应对象记录的内容。 Return true to suppress logging and return false to write to the log. 返回true以禁止日志记录,返回false以写入日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM