public void initialize() {
        if ((!(loggerFactory instanceof LoggerContext))) {
            System.err.println("Unable to initialize logback. It seems that slf4j is bound to an unexpected backend " + loggerFactory.getClass().getName());
            return;
        }

        File logbackFile = new File(configDir, childLogbackConfigFile);

        if (logbackFile.exists()) {
            System.err.println("Using logback configuration from file " + logbackFile);
            configureWith(logbackFile);
        } else {
            System.err.println("Could not find file `" + logbackFile + "'. Attempting to load from classpath.");
            String resourcePath = "config/" + childLogbackConfigFile;
            URL resource = getClass().getClassLoader().getResource(resourcePath);

            if (resource == null) {
                System.err.println("Could not find classpath resource `" + resourcePath + "'. Falling back to using a default logback configuration that writes to stdout.");
                configureDefaultLogging();
            } else {
                System.err.println("Using classpath resource `" + resource + "'.");
                configureWith(resource);
            }
        }
    }
@Test
    public void shouldUseDefaultConfigFromClasspathIfUserSpecifiedConfigFileIsNotFound() {
        final URL[] initializeFromPropertyResource = {null};
        LogConfigurator logConfigurator = new LogConfigurator("xxx", "logging-test-logback.xml") {
            @Override
            protected void configureWith(URL resource) {
                initializeFromPropertyResource[0] = resource;
            }
        };
        logConfigurator.initialize();

        URL expectedResource = getClass().getClassLoader().getResource("config/logging-test-logback.xml");
        assertThat(initializeFromPropertyResource[0], equalTo(expectedResource));

        assertThat(stderr.toString(), containsString("Using classpath resource `" + expectedResource + "'"));
        assertThat(stdout.toString(), is(""));
    }