From 3cfd4ab1d64e93b7061f7dc655216c091cd3b873 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Wed, 12 Jul 2017 07:59:42 +1000 Subject: [PATCH] docs(faq): added replaceConsole info --- docs/faq.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index 608e90c..6619dd6 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -25,3 +25,12 @@ logger.error('This goes to all-the-logs.log and oh-no-not-again.log'); ## I want to reload the configuration when I change my config file - how do I do that? Previous versions of log4js used to watch for changes in the configuration file and reload when it changed. It didn't always work well, sometimes leaving file handles or sockets open. This feature was removed in version 2.x. As a replacement, I'd suggest using a library like [watchr](https://www.npmjs.com/package/watchr) to notify you of file changes. Then you can call `log4js.shutdown` followed by `log4js.configure` again. + +## What happened to `replaceConsole` - it doesn't work any more? + +I removed `replaceConsole` - it caused a few weird errors, and I wasn't entirely comfortable with messing around with a core part of node. If you still want to do this, then code like this should do the trick: +```javascript +log4js.configure(...); // set up your categories and appenders +const logger = log4js.getLogger('console'); +console.log = logger.info.bind(logger); // do the same for others - console.debug, etc. +```