private void parseErrorHandler(
     final ErrorHandler eh,
     final String errorHandlerPrefix,
     final Properties props,
     final LoggerRepository hierarchy) {
   boolean rootRef =
       OptionConverter.toBoolean(
           OptionConverter.findAndSubst(errorHandlerPrefix + ROOT_REF, props), false);
   if (rootRef) {
     eh.setLogger(hierarchy.getRootLogger());
   }
   String loggerName = OptionConverter.findAndSubst(errorHandlerPrefix + LOGGER_REF, props);
   if (loggerName != null) {
     Logger logger =
         (loggerFactory == null)
             ? hierarchy.getLogger(loggerName)
             : hierarchy.getLogger(loggerName, loggerFactory);
     eh.setLogger(logger);
   }
   String appenderName =
       OptionConverter.findAndSubst(errorHandlerPrefix + APPENDER_REF_TAG, props);
   if (appenderName != null) {
     Appender backup = parseAppender(props, appenderName);
     if (backup != null) {
       eh.setBackupAppender(backup);
     }
   }
 }
 /** Parse the additivity option for a non-root category. */
 void parseAdditivityForLogger(Properties props, Logger cat, String loggerName) {
   String value = OptionConverter.findAndSubst(ADDITIVITY_PREFIX + loggerName, props);
   LogLog.debug("Handling " + ADDITIVITY_PREFIX + loggerName + "=[" + value + "]");
   // touch additivity only if necessary
   if ((value != null) && (!value.equals(""))) {
     boolean additivity = OptionConverter.toBoolean(value, true);
     LogLog.debug("Setting additivity for \"" + loggerName + "\" to " + additivity);
     cat.setAdditivity(additivity);
   }
 }
Esempio n. 3
0
  static {
    String prop = OptionConverter.getSystemProperty("java.version", null);

    if (prop != null) {
      int i = prop.indexOf('.');
      if (i != -1) {
        if (prop.charAt(i + 1) != '1') java1 = false;
      }
    }
    String ignoreTCLProp = OptionConverter.getSystemProperty("log4j.ignoreTCL", null);
    if (ignoreTCLProp != null) {
      ignoreTCL = OptionConverter.toBoolean(ignoreTCLProp, true);
    }
  }
  /**
   * Read configuration options from <code>properties</code>.
   *
   * <p>See {@link #doConfigure(String, LoggerRepository)} for the expected format.
   */
  public void doConfigure(Properties properties, LoggerRepository hierarchy) {
    repository = hierarchy;
    String value = properties.getProperty(LogLog.DEBUG_KEY);
    if (value == null) {
      value = properties.getProperty("log4j.configDebug");
      if (value != null)
        LogLog.warn("[log4j.configDebug] is deprecated. Use [log4j.debug] instead.");
    }

    if (value != null) {
      LogLog.setInternalDebugging(OptionConverter.toBoolean(value, true));
    }

    //
    //   if log4j.reset=true then
    //        reset hierarchy
    String reset = properties.getProperty(RESET_KEY);
    if (reset != null && OptionConverter.toBoolean(reset, false)) {
      hierarchy.resetConfiguration();
    }

    String thresholdStr = OptionConverter.findAndSubst(THRESHOLD_PREFIX, properties);
    if (thresholdStr != null) {
      hierarchy.setThreshold(OptionConverter.toLevel(thresholdStr, (Level) Level.ALL));
      LogLog.debug("Hierarchy threshold set to [" + hierarchy.getThreshold() + "].");
    }

    configureRootCategory(properties, hierarchy);
    configureLoggerFactory(properties);
    parseCatsAndRenderers(properties, hierarchy);

    LogLog.debug("Finished configuring.");
    // We don't want to hold references to appenders preventing their
    // garbage collection.
    registry.clear();
  }