Sails.js 禁用终端中的请求日志

Sails.js 禁用终端中的请求日志,sails.js,Sails.js,是否可以关闭sails请求日志。就像我不想看到下面粘贴的示例一样。因为当我运行集成测试时,这些日志会妨碍报告 <- PUT /api/v1/entrance/login (361ms 200) | The requesting user agent has been successfully logged in. | | Under the covers, this stores the id of the logged-in user in

是否可以关闭sails请求日志。就像我不想看到下面粘贴的示例一样。因为当我运行集成测试时,这些日志会妨碍报告

<- PUT /api/v1/entrance/login                 (361ms 200)
 |  The requesting user agent has been successfully logged in.
 |  
 |  Under the covers, this stores the id of the logged-in user in the session as the `userId` key.  The next time this user agent sends a request, assuming it includes a cookie (like a web browser), Sails will automatically make this user id available as req.session.userId in the corresponding action.  (Also note that, thanks to the included "custom" hook, when a relevant request is received from a logged-in user, that user's entire record from the database will be fetched and exposed as `req.me`.)
 |  
 ° 
<- GET /api/v1/user/me/overview/subscribe     (26ms 200)
如果您查看sails.js中关于日志的内容,您可以根据需要更改日志的级别。有几种方法可以实现这一点,但我更喜欢将日志级别放在env文件中,因为有些日志在生产中不需要,但在开发中是有意义的,而且很容易做到这一点:

//config/env/production.js
module.exports={
...
日志:{
级别:“调试”
}
...
}
这是帆钩。

阅读文档,您可以编辑日志或禁用其中的一些日志,或者卸载钩子


在项目根目录上运行
npm uninstall sails
,然后提起sails。

若要仅在生产中禁用请求日志记录,只需将添加到
config/env/production.js
,将
routesToLog
属性保留为空数组即可,因此,日志记录例程不会绑定到任何事件,因此不会产生任何开销。

我认为您设置了与我类似的测试用例

我在我的
/test/lifecycle.test.js
中添加了配置

“./lifecycle.test.js”在

当我在其中调用
sails.lift()
时,我添加了如下配置:

sails.lift(
{
日志:{level:'silent'},
apianalytics:{routesToLog:[]},
},

然后,我只能看到mocha日志。

谢谢,但我尝试了这个,我仍然可以看到这些“请求级别”日志。非常感谢!我已经断断续续地想了将近一个月了。我不想卸载那个钩子,所以我最后做的是在我的
sails.lift
测试套件的配置中禁用它:
钩子:{grunt:false,apianalytics:false},
有趣的想法matpop