Search in sources :

Example 11 with LoggerNameAndLevelFilter

use of org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter in project qpid-broker-j by apache.

the class LoggerNameAndLevelFilterTest method testDecideForNullLoggerName.

public void testDecideForNullLoggerName() throws Exception {
    LoggerNameAndLevelFilter filter = new LoggerNameAndLevelFilter(null, Level.INFO);
    ILoggingEvent event = mock(ILoggingEvent.class);
    when(event.getLevel()).thenReturn(Level.INFO);
    when(event.getLoggerName()).thenReturn("org.apache.qpid.server.foo");
    assertEquals("Unexpected reply for matching log level and arbitrary logger name", FilterReply.ACCEPT, filter.decide(event));
    when(event.getLoggerName()).thenReturn("org.apache.qpid.foo");
    assertEquals("Unexpected reply for matching log level and arbitrary logger name", FilterReply.ACCEPT, filter.decide(event));
    when(event.getLevel()).thenReturn(Level.DEBUG);
    assertEquals("Unexpected reply for non matching log level", FilterReply.NEUTRAL, filter.decide(event));
}
Also used : LoggerNameAndLevelFilter(org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Example 12 with LoggerNameAndLevelFilter

use of org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter in project qpid-broker-j by apache.

the class VirtualHostNameAndLevelLogInclusionRuleImplTest method testLevelChangeAffectsFilter.

public void testLevelChangeAffectsFilter() {
    VirtualHostNameAndLevelLogInclusionRule<?> rule = createRule("org.apache.qpid", LogLevel.INFO);
    LoggerNameAndLevelFilter filter = (LoggerNameAndLevelFilter) rule.asFilter();
    assertEquals("Unexpected log level", Level.INFO, filter.getLevel());
    rule.setAttributes(Collections.<String, Object>singletonMap("level", LogLevel.DEBUG));
    assertEquals("Unexpected log level attribute", Level.DEBUG, filter.getLevel());
}
Also used : LoggerNameAndLevelFilter(org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter)

Aggregations

LoggerNameAndLevelFilter (org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter)12 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)7 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)2 Logger (ch.qos.logback.classic.Logger)1