当我启动连接到 mongodb 的 Node 服务器时,我总是收到这些消息,告诉我连接的状态。如何禁用这些消息?
Wed Apr 24 13:28:17 [initandlisten] connection accepted from 127.0.0.1:55221 #304 (1 connection now open)
Wed Apr 24 13:28:17 [initandlisten] connection accepted from 127.0.0.1:55222 #305 (2 connections now open)
Wed Apr 24 13:28:17 [initandlisten] connection accepted from 127.0.0.1:55223 #306 (3 connections now open)
Wed Apr 24 13:28:17 [initandlisten] connection accepted from 127.0.0.1:55224 #307 (4 connections now open)
Wed Apr 24 13:28:17 [initandlisten] connection accepted from 127.0.0.1:55225 #308 (5 connections now open)
Wed Apr 24 13:35:42 [conn308] end connection 127.0.0.1:55225 (4 connections now open)
Wed Apr 24 13:35:42 [conn307] end connection 127.0.0.1:55224 (4 connections now open)
Wed Apr 24 13:35:42 [conn306] end connection 127.0.0.1:55223 (4 connections now open)
Wed Apr 24 13:35:42 [conn305] end connection 127.0.0.1:55222 (4 connections now open)
Wed Apr 24 13:35:42 [conn304] end connection 127.0.0.1:55221 (4 connections now open)
最佳答案
此消息不是来自node.js 或node-mongodb-native 驱动程序。它来自 mongo 守护进程。
启动 mongo 时,只需传递 --quiet 选项,此消息就会消失。
关于node.js - 如何在控制台中禁用 Node mongodb-native 驱动程序连接日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16200719/