use of org.apache.log4j.spi.RendererSupport in project logging-log4j2 by apache.
the class PropertyConfigurator method parseCatsAndRenderers.
/**
* Parse non-root elements, such non-root categories and renderers.
*/
protected void parseCatsAndRenderers(final Properties properties, final LoggerRepository loggerRepository) {
final Enumeration enumeration = properties.propertyNames();
while (enumeration.hasMoreElements()) {
final String key = (String) enumeration.nextElement();
if (key.startsWith(CATEGORY_PREFIX) || key.startsWith(LOGGER_PREFIX)) {
String loggerName = null;
if (key.startsWith(CATEGORY_PREFIX)) {
loggerName = key.substring(CATEGORY_PREFIX.length());
} else if (key.startsWith(LOGGER_PREFIX)) {
loggerName = key.substring(LOGGER_PREFIX.length());
}
final String value = OptionConverter.findAndSubst(key, properties);
final Logger logger = loggerRepository.getLogger(loggerName, loggerFactory);
synchronized (logger) {
parseCategory(properties, logger, key, loggerName, value);
parseAdditivityForLogger(properties, logger, loggerName);
}
} else if (key.startsWith(RENDERER_PREFIX)) {
final String renderedClass = key.substring(RENDERER_PREFIX.length());
final String renderingClass = OptionConverter.findAndSubst(key, properties);
if (loggerRepository instanceof RendererSupport) {
RendererMap.addRenderer((RendererSupport) loggerRepository, renderedClass, renderingClass);
}
} else if (key.equals(THROWABLE_RENDERER_PREFIX)) {
if (loggerRepository instanceof ThrowableRendererSupport) {
final ThrowableRenderer tr = (ThrowableRenderer) OptionConverter.instantiateByKey(properties, THROWABLE_RENDERER_PREFIX, org.apache.log4j.spi.ThrowableRenderer.class, null);
if (tr == null) {
LogLog.error("Could not instantiate throwableRenderer.");
} else {
final PropertySetter setter = new PropertySetter(tr);
setter.setProperties(properties, THROWABLE_RENDERER_PREFIX + ".");
((ThrowableRendererSupport) loggerRepository).setThrowableRenderer(tr);
}
}
}
}
}
Aggregations