Search in sources :

Example 6 with LoggerNameAndLevelFilter

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

the class VirtualHostNameAndLevelLogInclusionRuleImplTest method testLoggerNameChangeNotAllowed.

public void testLoggerNameChangeNotAllowed() {
    VirtualHostNameAndLevelLogInclusionRule<?> rule = createRule("org.apache.qpid", LogLevel.INFO);
    LoggerNameAndLevelFilter filter = (LoggerNameAndLevelFilter) rule.asFilter();
    assertEquals("Unexpected logger name", "org.apache.qpid", filter.getLoggerName());
    try {
        rule.setAttributes(Collections.<String, Object>singletonMap(BrokerNameAndLevelLogInclusionRule.LOGGER_NAME, "org.apache.qpid.foo"));
        fail("IllegalConfigurationException is expected to throw on attempt to change logger name");
    } catch (IllegalConfigurationException e) {
    // pass
    }
    assertEquals("Unexpected logger name", "org.apache.qpid", filter.getLoggerName());
}
Also used : LoggerNameAndLevelFilter(org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException)

Example 7 with LoggerNameAndLevelFilter

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

the class VirtualHostNameAndLevelLogInclusionRuleImplTest method testAsFilter.

public void testAsFilter() {
    VirtualHostNameAndLevelLogInclusionRule<?> rule = createRule("org.apache.qpid", LogLevel.INFO);
    Filter<ILoggingEvent> filter = rule.asFilter();
    assertTrue("Unexpected filter instance", filter instanceof LoggerNameAndLevelFilter);
    LoggerNameAndLevelFilter f = (LoggerNameAndLevelFilter) filter;
    assertEquals("Unexpected log level", Level.INFO, f.getLevel());
    assertEquals("Unexpected logger name", "org.apache.qpid", f.getLoggerName());
}
Also used : LoggerNameAndLevelFilter(org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Example 8 with LoggerNameAndLevelFilter

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

the class BrokerNameAndLevelLogInclusionRuleTest method testAsFilter.

public void testAsFilter() {
    BrokerNameAndLevelLogInclusionRule<?> rule = createRule("org.apache.qpid", LogLevel.INFO);
    Filter<ILoggingEvent> filter = rule.asFilter();
    assertTrue("Unexpected filter instance", filter instanceof LoggerNameAndLevelFilter);
    LoggerNameAndLevelFilter f = (LoggerNameAndLevelFilter) filter;
    assertEquals("Unexpected log level", Level.INFO, f.getLevel());
    assertEquals("Unexpected logger name", "org.apache.qpid", f.getLoggerName());
}
Also used : LoggerNameAndLevelFilter(org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Example 9 with LoggerNameAndLevelFilter

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

the class BrokerNameAndLevelLogInclusionRuleTest method testLoggerNameChangeNotAllowed.

public void testLoggerNameChangeNotAllowed() {
    BrokerNameAndLevelLogInclusionRule<?> rule = createRule("org.apache.qpid", LogLevel.INFO);
    LoggerNameAndLevelFilter filter = (LoggerNameAndLevelFilter) rule.asFilter();
    assertEquals("Unexpected logger name", "org.apache.qpid", filter.getLoggerName());
    try {
        rule.setAttributes(Collections.<String, Object>singletonMap(BrokerNameAndLevelLogInclusionRule.LOGGER_NAME, "org.apache.qpid.foo"));
        fail("IllegalConfigurationException is expected to throw on attempt to change logger name");
    } catch (IllegalConfigurationException e) {
    // pass
    }
    assertEquals("Unexpected logger name", "org.apache.qpid", filter.getLoggerName());
}
Also used : LoggerNameAndLevelFilter(org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException)

Example 10 with LoggerNameAndLevelFilter

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

the class LoggerNameAndLevelFilterTest method testDecideForEmptyLoggerName.

public void testDecideForEmptyLoggerName() throws Exception {
    LoggerNameAndLevelFilter filter = new LoggerNameAndLevelFilter("", 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 namel", 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)

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