文档菜单
文档首页
/ / /
Node.js 驱动程序
/

日志记录

本页内容

  • 临时替代方案

重要

从 4.0 版本开始,驱动程序不使用日志记录器。在此版本中尝试使用先前的日志记录器设置将不会在日志中打印任何内容。

相反,请参阅我们的监控指南

  • 命令监控

  • 集群监控

  • 连接池监控

我们正在开发一个新的日志框架。在此期间,您可以使用以下代码片段输出监控事件

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));

返回

排序规则

本页内容