在MongoDB中logging所有请求

我有一个nodejs-express-mongoose应用程序,我想设置日志logging系统。 我知道connect.logger()中间件,但我想login到MongoDB数据库。

我可以通过使用重写connect.logger()中间件来实现我的目的是一些快递插件吗?

mongoose有一个debug选项,用console.errorlogging所有的集合方法调用(update,insert,find,ensureIndex等)。 你也可以用你自己的自定义函数覆盖它:

 mongoose.set('debug', true) // for logging with console.error mongoose.set('debug', yourFunction) // to handle it yourself