From f7013a96949f12b65e71dd6474038aa83d1df59b Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Tue, 18 Apr 2017 08:07:02 +1000 Subject: [PATCH] docs(faq): added loglevelfilter example to faq --- docs/faq.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index e69de29..898f605 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -0,0 +1,23 @@ +# Frequently Asked Questions + +## I want errors to go to a special file, but still want everything written to another file - how do I do that? + +You'll need to use the [logLevelFilter](logLevelFilter.md). Here's an example configuration: +```javascript +log4js.configure({ + appenders: { + everything: { type: 'file', filename: 'all-the-logs.log' }, + emergencies: { type: 'file', filename: 'oh-no-not-again.log' }, + 'just-errors': { type: 'logLevelFilter', appender: 'emergencies', minLevel: 'error' } + }, + categories: { + default: { appenders: ['just-errors', 'everything'], level: 'debug' } + } +}); + +const logger = log4js.getLogger(); +logger.debug('This goes to all-the-logs.log'); +logger.info('As does this.'); +logger.error('This goes to all-the-logs.log and oh-no-not-again.log'); + +```