Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable HTTP request logs in Node/Express.js

Tags:

node.js

I'm currently working on an application based on Node/Express.js.

I have a lot of different resources files (images, css, js...) that I don't want to be logged when executing my application...

Exemple: my node application logs:

GET /stylesheets/bootstrap.min.css 200 0ms GET /js/lib/jquery-1.8.2.min.js 200 0ms GET /stylesheets/bootstrap-responsive.2.1.1.min.css 200 0ms GET /stylesheets/font-awesome.css 200 0ms GET /stylesheets/bootstrapSwitch.css 200 0ms GET /js/lib/jquery-ui-1.8.23.effects.min.js 200 0ms GET /js/lib/knockout-2.1.0.js 200 0ms GET /js/src/messages.manage.js 200 0ms GET /js/lib/bootstrap.2.1.1.min.js 200 0ms GET /js/lib/bootstrapSwitch.js 200 0ms ... 

My question is:

Can I remove these logs based on the extension of a file ? Example: *.js , *.css etc...

like image 678
gogson Avatar asked Apr 11 '13 15:04

gogson


2 Answers

Move the logging pluggin below the resource pluggin in the app initialization. Done.

Woohoo for Connect!

like image 114
cwharris Avatar answered Sep 20 '22 17:09

cwharris


On express.js 4,

comment: //app.use(morgan('dev'));

like image 39
Ignacio Pascual Avatar answered Sep 21 '22 17:09

Ignacio Pascual