Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running node.js without automatic logs

I would like to run my node.js application without the automatic logs it prints in the terminal when answering a request (for example 127.0.0.1 - - [Wed, 20 Jun 2012 09:55:49 GMT] "GET /url HTTP/1.1" 200 1559 "http://localhost:3020/url" ...). Moreover I would like that my logs from console.log() still remain visible if possible.

Does anyone know how to do this? I'm running express.js on top of Node.

Thanks

like image 854
Masiar Avatar asked Jun 20 '12 11:06

Masiar


1 Answers

Like brandon is saying I think you are using the logger middleware somewhere in your code. You should disable that part especially in production mode. Use something like this:

app.configure(function(){
    app.use(express.methodOverride());
    app.use(express.bodyParser());
    app.use(app.router);
});

app.configure('development', function(){
    app.use(express.static(__dirname + '/public'));
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure('production', function(){
  var oneYear = 31557600000;
  app.use(express.static(__dirname + '/public', { maxAge: oneYear }));
  app.use(express.errorHandler());
});
like image 183
Alfred Avatar answered Sep 22 '22 22:09

Alfred