我试图使用mongo-morgan。我像原始的摩根包一样使用它,但我在终端日志中没有得到任何回复。
我已尝试过此操作(更改' url'到我的数据库网址):
app.use(mongoMorgan('url', 'dev'));
和(来自mongo-morgan存储库):
app.use(mongoMorgan('url', 'combined', { collection: 'logs'}));
答案 0 :(得分:0)
mongomorgan has an onConnect() function. If you want to be notified whenever you get a connection to the database, i think you should log the message in this function. It's signature is
function onConnect(error, mongoDb)