public static Object instantiateByKey(Properties props, String key, Class superClass, Object defaultValue) { // Get the value of the property in string form String className = findAndSubst(key, props); if(className == null) { LogLog.error("Could not find value for key " + key); return defaultValue; } // Trim className to avoid trailing spaces that cause problems. return OptionConverter.instantiateByClassName(className.trim(), superClass, defaultValue); }
void configureRootCategory(Properties props, LoggerRepository hierarchy) { String effectiveFrefix = ROOT_LOGGER_PREFIX; String value = OptionConverter.findAndSubst(ROOT_LOGGER_PREFIX, props); if(value == null) { value = OptionConverter.findAndSubst(ROOT_CATEGORY_PREFIX, props); effectiveFrefix = ROOT_CATEGORY_PREFIX; } if(value == null) LogLog.debug("Could not find root logger information. Is this OK?"); else { Logger root = hierarchy.getRootLogger(); synchronized(root) { parseCategory(props, root, effectiveFrefix, INTERNAL_ROOT_NAME, value); } } }
loggerName = key.substring(LOGGER_PREFIX.length()); String value = OptionConverter.findAndSubst(key, props); Logger logger = hierarchy.getLogger(loggerName, loggerFactory); synchronized(logger) { String renderingClass = OptionConverter.findAndSubst(key, props); if(hierarchy instanceof RendererSupport) { RendererMap.addRenderer((RendererSupport) hierarchy, renderedClass,
/** 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); } }
String value = OptionConverter.findAndSubst(key, properties); key = key.substring(len); if (("layout".equals(key) || "errorhandler".equals(key)) && obj instanceof Appender) {
String value = OptionConverter.findAndSubst(key, props); filterOpts.add(new NameValue(name, value));
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); } } }
/** Check the provided <code>Properties</code> object for a {@link org.apache.log4j.spi.LoggerFactory LoggerFactory} entry specified by {@link #LOGGER_FACTORY_KEY}. If such an entry exists, an attempt is made to create an instance using the default constructor. This instance is used for subsequent Category creations within this configurator. @see #parseCatsAndRenderers */ protected void configureLoggerFactory(Properties props) { String factoryClassName = OptionConverter.findAndSubst(LOGGER_FACTORY_KEY, props); if(factoryClassName != null) { LogLog.debug("Setting category factory to ["+factoryClassName+"]."); loggerFactory = (LoggerFactory) OptionConverter.instantiateByClassName(factoryClassName, LoggerFactory.class, loggerFactory); PropertySetter.setProperties(loggerFactory, props, FACTORY_PREFIX + "."); } }
String thresholdStr = OptionConverter.findAndSubst(THRESHOLD_PREFIX, properties); if(thresholdStr != null) {
String errorHandlerClass = OptionConverter.findAndSubst(errorHandlerPrefix, props); if (errorHandlerClass != null) { ErrorHandler eh = (ErrorHandler) OptionConverter.instantiateByKey(props,
public static Object instantiateByKey(Properties props, String key, Class superClass, Object defaultValue) { // Get the value of the property in string form String className = findAndSubst(key, props); if(className == null) { LogLog.error("Could not find value for key " + key); return defaultValue; } // Trim className to avoid trailing spaces that cause problems. return OptionConverter.instantiateByClassName(className.trim(), superClass, defaultValue); }
void configureRootCategory(Properties props, LoggerRepository hierarchy) { String effectiveFrefix = ROOT_LOGGER_PREFIX; String value = OptionConverter.findAndSubst(ROOT_LOGGER_PREFIX, props); if(value == null) { value = OptionConverter.findAndSubst(ROOT_CATEGORY_PREFIX, props); effectiveFrefix = ROOT_CATEGORY_PREFIX; } if(value == null) LogLog.debug("Could not find root logger information. Is this OK?"); else { Logger root = hierarchy.getRootLogger(); synchronized(root) { parseCategory(props, root, effectiveFrefix, INTERNAL_ROOT_NAME, value); } } }
void configureRootCategory(Properties props, LoggerRepository hierarchy) { String effectiveFrefix = ROOT_LOGGER_PREFIX; String value = OptionConverter.findAndSubst(ROOT_LOGGER_PREFIX, props); if(value == null) { value = OptionConverter.findAndSubst(ROOT_CATEGORY_PREFIX, props); effectiveFrefix = ROOT_CATEGORY_PREFIX; } if(value == null) { LogLog.debug("Could not find root logger information. Is this OK?"); } else { Logger root = hierarchy.getRootLogger(); synchronized(root) { parseCategory(props, root, effectiveFrefix, INTERNAL_ROOT_NAME, value); } } }
public static Object instantiateByKey(Properties props, String key, Class superClass, Object defaultValue) { // Get the value of the property in string form String className = findAndSubst(key, props); if(className == null) { LogLog.error("Could not find value for key " + key); return defaultValue; } // Trim className to avoid trailing spaces that cause problems. return OptionConverter.instantiateByClassName(className.trim(), superClass, defaultValue); }
String value = OptionConverter.findAndSubst(key, properties); key = key.substring(len); if ("layout".equals(key) && obj instanceof Appender) {
/** 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); } }
/** 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); } }
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); } } }
/** Check the provided <code>Properties</code> object for a {@link org.apache.log4j.spi.LoggerFactory LoggerFactory} entry specified by {@link #LOGGER_FACTORY_KEY}. If such an entry exists, an attempt is made to create an instance using the default constructor. This instance is used for subsequent Category creations within this configurator. @see #parseCatsAndRenderers */ protected void configureLoggerFactory(Properties props) { String factoryClassName = OptionConverter.findAndSubst(LOGGER_FACTORY_KEY, props); if(factoryClassName != null) { LogLog.debug("Setting category factory to ["+factoryClassName+"]."); loggerFactory = (LoggerFactory) OptionConverter.instantiateByClassName(factoryClassName, LoggerFactory.class, loggerFactory); PropertySetter.setProperties(loggerFactory, props, FACTORY_PREFIX + "."); } }
/** Check the provided <code>Properties</code> object for a {@link org.apache.log4j.spi.LoggerFactory LoggerFactory} entry specified by {@link #LOGGER_FACTORY_KEY}. If such an entry exists, an attempt is made to create an instance using the default constructor. This instance is used for subsequent Category creations within this configurator. @see #parseCatsAndRenderers */ protected void configureLoggerFactory(Properties props) { String factoryClassName = OptionConverter.findAndSubst(LOGGER_FACTORY_KEY, props); if(factoryClassName != null) { LogLog.debug("Setting category factory to ["+factoryClassName+"]."); loggerFactory = (LoggerFactory) OptionConverter.instantiateByClassName(factoryClassName, LoggerFactory.class, loggerFactory); PropertySetter.setProperties(loggerFactory, props, FACTORY_PREFIX + "."); } }