javascript - Tracking each request logs in Express JS -


i having web application build on node , express in backend. web site having lot of users logs confusing when try debug of logs(console.log) in case of issues. logs clumsy among different users, there way track logs respect request (request id kinda thing)?

recommend simple log middleware, example https://github.com/villadora/express-bunyan-logger

app.use(require('express-bunyan-logger').errorlogger()); app.use(require('express-bunyan-logger')({     name: 'logger',     streams: [{         level: 'info',         stream: process.stdout         }]     }));  app.use(require('express-bunyan-logger')({     format: ":remote-address - :user-agent[major] custom logger" });  app.use(require('express-bunyan-logger')(); app.use(function(req, res, next) {     req.log.debug('this debug in middleware');     next(); }); 

you can castumize logger, write difference data file ot stdout.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -