Java Code Examples for ch.qos.logback.classic.Logger#isInfoEnabled()

The following examples show how to use ch.qos.logback.classic.Logger#isInfoEnabled() . 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: UimaLoggingTest.java    From baleen with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws Exception {
  BaleenLogging logging = new BaleenLogging();
  InMemoryLoggingBuilder builder = new InMemoryLoggingBuilder();
  logging.configure(Collections.singletonList(builder));

  InMemoryAppender<ILoggingEvent> appender = builder.getAppender();
  appender.clear();

  LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
  Logger rootLogger = context.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);

  if (rootLogger.isInfoEnabled()) {
    UIMAFramework.getLogger(DummyAnnotator1.class).log(Level.INFO, "Logging from uima");

    assertTrue(
        appender.getAll().stream()
                .filter(l -> l.getMessage().contains("Logging from uima"))
                .count()
            > 0);
  }
}
 
Example 2
Source File: QpidLoggerTurboFilterTest.java    From qpid-broker-j with Apache License 2.0 4 votes vote down vote up
@Test
public void testInstallFilterWorksCorrectly()
{
    Logger fooBarLogger = _loggerContext.getLogger("foo.bar");
    if(fooBarLogger.isDebugEnabled())
    {
        fail("debug should not be enabled by default");
    }
    if(fooBarLogger.isInfoEnabled())
    {
        fail("info should not be enabled by default");
    }

    final LoggerNameAndLevelFilter allFooInfo = new LoggerNameAndLevelFilter("foo.*", Level.INFO);
    _turboFilter.filterAdded(allFooInfo);

    if(!fooBarLogger.isInfoEnabled())
    {
        fail("info should be enabled after filter added");
    }
    if(fooBarLogger.isDebugEnabled())
    {
        fail("debug should not be enabled after info enabled");
    }

    final LoggerNameAndLevelFilter fooBarDebugFilter = new LoggerNameAndLevelFilter("foo.bar", Level.DEBUG);
    _turboFilter.filterAdded(fooBarDebugFilter);
    if(!fooBarLogger.isDebugEnabled())
    {
        fail("debug should now be enabled");
    }
    final Logger fooBazLogger = _loggerContext.getLogger("foo.baz");
    if(fooBazLogger.isDebugEnabled())
    {
        fail("debug should not be enabled after for foo.baz");
    }

    _turboFilter.filterRemoved(allFooInfo);
    if(!fooBarLogger.isInfoEnabled())
    {
        fail("info should be still be enabled fo foo.bar");
    }

    if(fooBazLogger.isInfoEnabled())
    {
        fail("info should not still be enabled fo foo.baz");
    }
}