Java 类ch.qos.logback.classic.spi.Configurator 实例源码

项目:bartleby    文件:ContextInitializer.java   
public void autoConfig() throws JoranException {
  StatusListenerConfigHelper.installIfAsked(loggerContext);
  URL url = findURLOfDefaultConfigurationFile(true);
  if (url != null) {
    configureByResource(url);
  } else {
    Configurator c = EnvUtil.loadFromServiceLoader(Configurator.class);
    if (c != null) {
      try {
        c.setContext(loggerContext);
        c.configure(loggerContext);
      } catch (Exception e) {
        throw new LogbackException(String.format("Failed to initialize Configurator: %s using ServiceLoader", 
            c != null ? c.getClass().getCanonicalName() : "null"), e);
      }
    } else {
      BasicConfigurator.configure(loggerContext);
    }
  }
}