Java Code Examples for ch.qos.logback.core.util.StatusPrinter#print()

The following examples show how to use ch.qos.logback.core.util.StatusPrinter#print() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConsoleLogApplicationTests.java    From spring-cloud-formula with Apache License 2.0 6 votes vote down vote up
@Test
public void contextLoads() {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    String val = context.getProperty(SpacedLogbackSystem.KEY_ENABLED);
    Assert.assertEquals("true", val);
    Logger logger = context.getLogger("com.baidu");
    Assert.assertEquals(Level.DEBUG, logger.getLevel());
    logger = context.getLogger("com.baidu.ebiz");
    Assert.assertEquals(Level.WARN, logger.getLevel());

    logger = context.getLogger("ROOT");
    List<Appender<ILoggingEvent>> list = StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(
                    logger.iteratorForAppenders(), Spliterator.ORDERED), false)
            .collect(Collectors.toList());

    Assert.assertThat(list.size(), Matchers.greaterThan(1));

    LoggerFactory.getLogger("com.baidu").info("info for root");
    StatusPrinter.print(context);
}
 
Example 2
Source File: LogbackConfiguration.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void load() throws IOException {
	try {
		if (System.getProperty(LOGGING_DIR_PROPERTY) == null) {
			System.setProperty(LOGGING_DIR_PROPERTY, getLoggingDir().getAbsolutePath());
		}
	} catch (SecurityException e) {
		System.out.println("Not allowed to read or write system property '" + LOGGING_DIR_PROPERTY + "'");
	}

	LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
	try {
		configurator = new LogConfigurator();
		configurator.setContext(lc);
		lc.reset();
		configurator.doConfigure(configFile);
	} catch (JoranException je) {
		System.out.println("Logback configuration error");
		je.printStackTrace();
		StatusPrinter.print(lc);
	}
}
 
Example 3
Source File: RedisBatchAppenderEmbeddedIT.java    From logback-redis with Apache License 2.0 4 votes vote down vote up
private static void logStatus() {
    // assume SLF4J is bound to logback in the current environment
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    // print logback's internal status
    StatusPrinter.print(lc);
}