0

Is it advisable to have 2 log4js logging in my nodejs application.

Logger A (The standard logger) to file A:

  • Print out / Info
  • Error
  • Warning

Logger B (Performance logger) to file B:

  • Logs only performance (i.e. time taken to complete this transaction)

Both logger logging to 2 different files.

shadow
  • 800
  • 2
  • 16
  • 33

1 Answers1

0

I would integrate it only once and implement the following logic:

In Code use

logger.debug('Performance info');
logger.info('Print out / Info');
logger.warn('Warning');
logger.error('Error');
  • In development mode: set the logger level to debug
  • In staging/test mode if any: set the logger level to info
  • In production mode: set the logger level to warn
Kossi D. T. S.
  • 484
  • 2
  • 10
  • What if i need to logged to 2 different files? – shadow Jan 21 '19 at 09:00
  • 1
    As in https://log4js-node.github.io/log4js-node/logLevelFilter.html use can configure multiple appenders to point to different log files and additionally some appenders of type `logLevelFilter` with `level` (and `maxLevel`) to filter/pipe the logs to the appropriate target log files using only one logger (the default category) – Kossi D. T. S. Jan 21 '19 at 11:11