禁用终端中的请求日志

问题描述 投票:0回答:2

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

<- 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
2个回答
1
投票

这是风帆钩。 https://www.npmjs.com/package/sails-hook-apianalytics

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

在项目的根目录上运行npm uninstall sails-hook-apianalytics然后抬起风帆。


1
投票

如果您检查sails.js documentation有关日志的信息,您可以根据需要更改日志级别。有几种方法可以实现这一点,但我更喜欢将日志级别放在env文件中,因为在生产中不需要某些日志,但在开发中有意义且易于执行此操作:

// config/env/production.js
module.exports = {
  ...
  log: {
    level: 'debug'
  }
  ...
}
© www.soinside.com 2019 - 2024. All rights reserved.