@param hierarchy The {@link org.apache.log4j.Hierarchy} to act on.
@since 1.1.4 */
public static void selectAndConfigure(
URL url, String clazz, LoggerRepository repository) {
Configurator configurator = null;
String filename = url.getFile();
if ((clazz == null) && (filename != null) && filename.endsWith(".xml")) {
clazz = JoranConfigurator.class.getName();
}
if (clazz != null) {
Logger logger = repository.getLogger(OptionConverter.class.getName());
logger.info("Preferred configurator class: " + clazz);
configurator =
(Configurator) instantiateByClassName(clazz, Configurator.class, null);
if (configurator == null) {
logger.error("Could not instantiate configurator [" + clazz + "].");
return;
}
} else {
configurator = new PropertyConfigurator();
}
configurator.doConfigure(url, repository);
if(configurator instanceof ConfiguratorBase) {
((ConfiguratorBase)configurator).dumpErrors();
}
}