Logging登录中

Important重要的

The driver doesn't use the logger in versions 4.0 and later. 驱动程序不使用4.0及更高版本中的记录器。Attempting to use prior logger settings in this version won't print anything in the log.尝试在此版本中使用以前的记录器设置不会在日志中打印任何内容。

Instead, see our monitoring guides:

The Node.js team is currently working on rewriting the logger. Node.js团队目前正在重写记录器。In the meantime, you can output monitor events using the following snippet:同时,您可以使用以下代码段输出监控器事件:

const uri = "mongodb+srv://<user>:<password>@<cluster-url>?writeConcern=majority";
const client = new MongoClient(uri, { monitorCommands:true });
client.on('commandStarted', (event) => console.debug(event)); client.on('commandSucceeded', (event) => console.debug(event)); client.on('commandFailed', (event) => console.debug(event));