2017-08-11 109 views
0

我对猫鼬运行发现:如何获得更多关于猫鼬错误信息的详细信息?

var mongoose = require("mongoose"); 
let User = require("@myRepo/myapp").user; 

function getUser(){ 
    mongoose.set("debug", true); 

    User.find({ _id: currentUserId }) 
     .limit(1) 
     .exec(function(err, user) { 
     if (err) { 
      console.log("err: " + err); 
      throw err; 
     } 

     console.log("user: ", user); 
     }); 
} 

查找运行成功,但Exec之前每次运行在控制台上的日志出现在猫鼬的错误。没有错误的功能(错误,用户)被抛出!

这是一个猫鼬错误:

myapp  | [2017-08-11T15:30:38.505Z] ERROR: sys/289 on 58e82c8426b7: Mongoose: user.find({ _id: 10646 }, { limit: 1, fields: {} }) (type=app) 

有这个猫鼬错误没有详细信息。我怎样才能分析这个错误?

mongoose.set(“debug”,true); - 没有效果

回答

0

消息:

myapp  | [2017-08-11T15:30:38.505Z] ERROR: sys/289 on 58e82c8426b7: Mongoose: user.find({ _id: 10646 }, { limit: 1, fields: {} }) (type=app) 

是一个典型的猫鼬登录消息中猫鼬调试模式。消息中的文本“ERROR:”在我看来是一个错误。

如果你对此有何评论或代码删除所有

mongoose.set("debug", true); 

,并设置config日志级别为“信息”或更低

logging: { 
    level: "info" 
}, 

所有登录信息(在我们的情况与“错误的所有消息: “)消失。