Search in sources :

Example 1 with LoggerNameAndLevelFilter

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

the class BrokerNameAndLevelLogInclusionRuleTest method testLevelChangeAffectsFilter.

public void testLevelChangeAffectsFilter() {
    BrokerNameAndLevelLogInclusionRule<?> 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)

Example 2 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 3 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 4 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 5 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)

Aggregations

LoggerNameAndLevelFilter (org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter)6 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)2 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)2