How to use the replaceConsole function from log4js

Find comprehensive JavaScript log4js.replaceConsole code examples handpicked from public code repositorys.

55
56
57
58
59
60
61
62
63
64
const initLogging = (logLevel, config) => {
  // log4js.configure() modifies exports.logconfig so check for equality first.
  const logConfigIsDefault = deepEqual(config, defaultLogConfig());
  log4js.configure(config);
  log4js.setGlobalLogLevel(logLevel);
  log4js.replaceConsole();
  // Log the warning after configuring log4js to increase the chances the user will see it.
  if (!logConfigIsDefault) logger.warn('The logconfig setting is deprecated.');
};

fork icon0
star icon0
watch icon1

+ 4 other calls in file

28
29
30
31
32
33
34
35
36
37
38
39


const settings = require('./utils/Settings');


let wtfnode;
if (settings.dumpOnUncleanExit) {
  // wtfnode should be loaded after log4js.replaceConsole() so that it uses log4js for logging, and
  // it should be above everything else so that it can hook in before resources are used.
  wtfnode = require('wtfnode');
}

fork icon0
star icon0
watch icon0