mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
docs(faq): added loglevelfilter example to faq
This commit is contained in:
parent
f1ea44afd4
commit
f7013a9694
23
docs/faq.md
23
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');
|
||||
|
||||
```
|
||||
Loading…
x
Reference in New Issue
Block a user