Express logger unique request id
Logger that creates a unique id for each express request and prints it at the end of each line. It works with callbacks, promises (async - await).
npm install express-logger-unique-req-id --save
var express= ;var app = ;var express_logger = ;express_logger;let logger = express_logger;logger;
As this library uses node asynchronous and contexts, it's important to assign it to the middleware in the right order. This means, if there are other libraries that uses this characteristics too can affect to the good performance of the library. If body-parser library is used, express-logger-unique-req-id library has to be assign to the middleware after body-parser. Other case, the library could have unexpected behaviour. In the rest of cases the general rule is to assign it to the middleware as soon as possible.
As this library uses
Winston as logger, you can configure the File and the Console transports with the same information as you would use with winston
var express= ;var app = ;var express_logger = ;//logger configurationconst fileConf =level: 'debug'filename: './logs.log'handleExceptions: truejson: truemaxsize: 5242880 // 5MBmaxFiles: 5colorize: falsetimestamp: true;const consoleConf =level: 'debug'handleExceptions: truejson: falsecolorize: truetimestamp: true;express_logger;let logger = express_logger;logger;
For more info about the logger configuration posibilities: