如何在我的快递项目中配置mongo morgan?

时间:2018-02-05 12:10:17

标签: node.js mongodb express npm morgan

我试图使用mongo-morgan。我像原始的摩根包一样使用它,但我在终端日志中没有得到任何回复。

我已尝试过此操作(更改' url'到我的数据库网址):

app.use(mongoMorgan('url', 'dev'));

和(来自mongo-morgan存储库):

app.use(mongoMorgan('url', 'combined', { collection: 'logs'}));

1 个答案:

答案 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)