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 ex
On express.js 4,
comment: //app.use(morgan('dev'));
maybe this helps
app.use((req, res, next) => {
if (
[
".css",
".js",
".jpg",
".jpeg",
".gif",
".ico",
".png",
".bmp",
".pict",
".csv",
".doc",
".pdf",
".pls",
".ppt",
".tif",
".tiff",
".eps",
".ejs",
".swf",
".midi",
".mid",
".ttf",
".eot",
".woff",
".woff2",
".otf",
".svg",
".svgz",
".webp",
".docx",
".xlsx",
".xls",
".pptx",
".ps",
".class",
".jar"
].indexOf(path.extname(req.path)) == -1
) {
logger("dev")(req, res, next);
} else {
next();
}
});
Move the logging pluggin below the resource pluggin in the app initialization. Done.
Woohoo for Connect!