如何阻止NodeJS向控制台打印GET请求

时间:2016-06-26 13:27:39

标签: node.js console.log

NodeJs正在将每个GET请求(.js文件,.css文件等)打印到控制台。

...   
    GET /plugins/jquery.parallax-1.1.3.js 304 0.652 ms - -
    GET /plugins/jquery.validate.js 304 0.434 ms - -
    GET /plugins/vide/jquery.vide.js 304 0.910 ms - -
    GET /plugins/owl-carousel/owl.carousel.js 304 0.700 ms - -
...

有没有办法阻止Node将这些打印到控制台?

这是我的package.json

{
  "name": "ExPlatform",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "bcrypt-nodejs": "0.0.3",
    "body-parser": "~1.12.0",
    "connect-flash": "^0.1.1",
    "cookie-parser": "~1.3.4",
    "debug": "~2.1.1",
    "ejs": "~2.3.1",
    "express": "~4.12.2",
    "express-session": "^1.13.0",
    "fs": "0.0.2",
    "gm": "^1.21.1",
    "imagemagick": "^0.1.3",
    "mongoose": "^4.3.7",
    "mongoose-crate": "^1.0.10",
    "mongoose-crate-localfs": "^1.1.1",
    "morgan": "~1.5.1",
    "multer": "^1.1.0",
    "passport": "^0.3.2",
    "passport-local": "^1.0.0",
    "serve-favicon": "~2.2.0",
    "jsonfile": "^2.3.0",
    "nodemailer": "^2.4.2",
    "fast-csv": "^2.0.0",
    "fluent-logger": "^1.1.1"
  }
}

谢谢。

2 个答案:

答案 0 :(得分:1)

它的helmet包使用connect包下面使用debug包来记录每个http请求,只需删除此行

var helmet = require('helmet');
app.use(helmet());

使用npm uninstall helmet --save

卸载它

摩根也用来记录,检查出来https://github.com/expressjs/morgan

答案 1 :(得分:1)

发现这是morgan模块正在执行此操作。 我有app.user(logger('dev'));

相关问题