How could I suppress these log messages:

GET /stylesheets/style.css 500 451ms - 1.08kb Get /scripts/script.js 200 985ms - 91b

Or atleast get them to not change my console's background and foreground colors.

有帮助吗?

解决方案

0) remove the logger middleware

Comment out app.use(express.logger()) from your code...or make it conditional on your node environment settings so you get stuff in dev but not in production.

1) Use a different logger

You can search around for this in npm and you'll find things like express-winston.

2) Write your own logger

If what you need is simple, here's the example that's straight from the docs:

app.use(function(req, res, next){
  console.log('%s %s', req.method, req.url);
  next();
});

其他提示

Remove express.logger

app.set('view engine', 'jade')
app.configure(function() {
 // ̶a̶p̶p̶.̶u̶s̶e̶(̶e̶x̶p̶r̶e̶s̶s̶.̶l̶o̶g̶g̶e̶r̶(̶'̶d̶e̶v̶'̶)̶)̶;
    app.use(stylus.middleware({
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top