Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我看不到driver在 go 中为官方 mongo 启用日志/调试的方法。
driver
mgo有SetLogger
SetLogger
官方的 mongo 驱动程序不支持像 mgo 那样的记录器。您必须自己登录。我更喜欢这种方法,因为它让我可以完全控制要记录的内容和时间。
官方文档在所有示例中都使用了内置的日志模块。我自己使用logrus。
那是因为没有办法将记录器设置为mongo-go. 原因是mongo-go驱动程序没有记录任何内容。如果某处发生错误,它会返回一个错误并且不会记录它。它也不会记录“信息”或“警告”级别的消息。
mongo-go