Simple logging module for microsystems that wraps winston and continuation-local-storage.
What we ultimately wanted to achieve is to generate microservice logs that are unique, traceable, and contain enough data to act on quickly and effectively. To create these logs: * Append a unique identifier to requests as they enter the architecture. * Identify the service that generates events. * Generate events specific to each microservice as the request enters and leaves the service. * Correlate events from each microservice to create an overall view of the request.
npm install micro-logging
var log = require('micro-logging'); log.info('hello world'); log.debug('hello world', 'Meta Data')
- API Name - Set as serverName in Config
- Log Level - Set as logLevel in Config
- Correlation id - Set as correlationid in context
- Client Application - Set as clientapplication in context
- Global User Id - Set as globaluserid in context
- Meta data
Set Context in calling application
var session = require('continuation-local-storage').createNamespace('request'); session.set('correlationid', req.headers.correlationid); session.set('clientapplication', req.headers.clientapplication); session.set('globaluserid', req.headers.globaluserid);
serverName=Api Name logLevel=info, error, debug etc...