Examples of LoggerRepository


Examples of org.apache.log4j.spi.LoggerRepository

        }
      };
     
      final Logger originalRootLogger = LogManager.getRootLogger();
     
      final LoggerRepository parentRepository = originalRootLogger.getLoggerRepository();
     
      final LoggerRepository repository = new ThreadLocalAwareLoggerRepository(originalRootLogger, parentRepository, loggerFactory);
     
      LogManager.setRepositorySelector(new RepositorySelector() {
       
        @Override
        public LoggerRepository getLoggerRepository() {
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

  void testDisable1() {
    CountingAppender caRoot = new CountingAppender();
    Logger root = Logger.getRootLogger();   
    root.addAppender(caRoot);

    LoggerRepository h = LogManager.getLoggerRepository();
    //h.disableDebug();
    h.setThreshold((Level) Level.INFO);
    assertEquals(caRoot.counter, 0);    

    root.debug(MSG); assertEquals(caRoot.counter, 0)
    root.info(MSG); assertEquals(caRoot.counter, 1)
    root.log(Level.WARN, MSG); assertEquals(caRoot.counter, 2)
    root.warn(MSG); assertEquals(caRoot.counter, 3)

    //h.disableInfo();
    h.setThreshold((Level) Level.WARN);
    root.debug(MSG); assertEquals(caRoot.counter, 3)
    root.info(MSG); assertEquals(caRoot.counter, 3)
    root.log(Level.WARN, MSG); assertEquals(caRoot.counter, 4)
    root.error(MSG); assertEquals(caRoot.counter, 5)
    root.log(Level.ERROR, MSG); assertEquals(caRoot.counter, 6)

    //h.disableAll();
    h.setThreshold(Level.OFF);
    root.debug(MSG); assertEquals(caRoot.counter, 6)
    root.info(MSG); assertEquals(caRoot.counter, 6)
    root.log(Level.WARN, MSG); assertEquals(caRoot.counter, 6)
    root.error(MSG); assertEquals(caRoot.counter, 6)
    root.log(Level.FATAL, MSG); assertEquals(caRoot.counter, 6)
    root.log(Level.FATAL, MSG); assertEquals(caRoot.counter, 6)

    //h.disable(Level.FATAL);
    h.setThreshold(Level.OFF);
    root.debug(MSG); assertEquals(caRoot.counter, 6)
    root.info(MSG); assertEquals(caRoot.counter, 6)
    root.log(Level.WARN, MSG); assertEquals(caRoot.counter, 6)
    root.error(MSG); assertEquals(caRoot.counter, 6);
    root.log(Level.ERROR, MSG); assertEquals(caRoot.counter, 6)
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

    Connection connection = null;

    try {
      Logger logger;
      LoggerRepository loggerRepository = parentDBReceiver
          .getLoggerRepository();
      connection = parentDBReceiver.connectionSource.getConnection();

      StringBuffer sql = new StringBuffer();
      sql.append("SELECT ");
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

      System.out.println(
        "About to detach logger context named [" + loggingContextName + "].");

      RepositorySelector repositorySelector =
        LogManager.getRepositorySelector();
      LoggerRepository lr = repositorySelector.detachRepository(loggingContextName);
      if(lr != null) {
        Logger logger = lr.getLogger(this.getClass().getName());
        logger.debug("About to shutdown logger repository named [{}]", lr.getName());
        lr.shutdown();
      }
    }
  }
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

      throw new IllegalStateException(errMsg);
    }
  }
 
  public void setProperties(ExecutionContext ec, Properties props) {
    LoggerRepository repository = getLoggerRepository(ec);
    repository.getProperties().putAll(props);
  }
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

    LoggerRepository repository = getLoggerRepository(ec);
    repository.getProperties().putAll(props);
  }
 
  public void setProperty(ExecutionContext ec, String key, String value) {
    LoggerRepository repository = getLoggerRepository(ec);
    repository.setProperty(key, value);
 
  }
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

    try {
      getLogger().debug(
        "About to add conversion rule [{}, {}] to layout", conversionWord, converterClass);

      LoggerRepository repository = (LoggerRepository) ec.getObjectStack().get(0);

      Map ruleRegistry = (Map) repository.getObject(PatternLayout.PATTERN_RULE_REGISTRY);
      if(ruleRegistry == null) {
        ruleRegistry = new HashMap();
        repository.putObject(PatternLayout.PATTERN_RULE_REGISTRY, ruleRegistry);
      }
      // put the new rule into the rule registry
      ruleRegistry.put(conversionWord, converterClass);
 
    } catch (Exception oops) {
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

      } else {
        plugin.setName(pluginName);
        getLogger().debug("plugin named as [" + pluginName + "]");
      }

      LoggerRepository repository = (LoggerRepository) ec.getObject(0);
     
      repository.getPluginRegistry().addPlugin(plugin);
      plugin.setLoggerRepository(repository);
     
      getLogger().debug("Pushing plugin on to the object stack.");
      ec.pushObject(plugin);
    } catch (Exception oops) {
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

        log.trace("Syncing up JDK logger levels from Log4j");
        final Map<Logger, java.util.logging.Logger> loggerMap = this.loggerMap;
        final LevelMapper levelMapper = this.levelMapper;
        loggerMap.clear();
        final Logger rootLogger = Logger.getRootLogger();
        final LoggerRepository repository = rootLogger.getLoggerRepository();
        final Enumeration loggers = repository.getCurrentLoggers();
        while (loggers.hasMoreElements()) {
            final Logger logger = (Logger) loggers.nextElement();
            final String name = logger.getName();
            final java.util.logging.Logger jdkLogger = java.util.logging.Logger.getLogger(name);
            final org.apache.log4j.Level targetLevel = logger.getLevel();
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

  }

  public static void withDisabledLogging(final Runnable r)
  {
    // Note: this assumes we're using Log4J and needs to be fixed up if this changes.
    final LoggerRepository loggerRepo = LogManager.getLoggerRepository();
    final Level oldLevel = loggerRepo.getThreshold();
    loggerRepo.setThreshold(Level.OFF);
    try
    {
      r.run();
    }
    finally
    {
      loggerRepo.setThreshold(oldLevel);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.