log4js-node

A port of log4js to node.js

View the Project on GitHub

Category Filter

This is not strictly an appender - it wraps around another appender and stops log events from specific categories from being written to that appender. This could be useful when debugging your application, but you have one component that logs noisily, or is irrelevant to your investigation.

Configuration

Example

log4js.configure({
  appenders: {
    everything: { type: 'file', filename: 'all-the-logs.log' },
    'no-noise': { type: 'categoryFilter', exclude: 'noisy.component', appender: 'everything' }
  },
  categories: {
    default: { appenders: [ 'no-noise' ], level: 'debug' }
  }
});

const logger = log4js.getLogger();
const noisyLogger = log4js.getLogger('noisy.component');
logger.debug('I will be logged in all-the-logs.log');
noisyLogger.debug('I will not be logged.');