Search in sources :

Example 1 with VirtualHostLogger

use of org.apache.qpid.server.model.VirtualHostLogger in project qpid-broker-j by apache.

the class VirtualHostLoggerTest method testLoggersRemovedOnVirtualHostClose.

@Test
public void testLoggersRemovedOnVirtualHostClose() {
    VirtualHostLogger logger = createVirtualHostLogger();
    _virtualHost.close();
    Appender<ILoggingEvent> appender = ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).getAppender(logger.getName());
    assertNull("Appender was not deleted", appender);
}
Also used : VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) EventLogger(org.apache.qpid.server.logging.EventLogger) Logger(org.slf4j.Logger) VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) Test(org.junit.Test)

Example 2 with VirtualHostLogger

use of org.apache.qpid.server.model.VirtualHostLogger in project qpid-broker-j by apache.

the class VirtualHostLoggerTest method testLoggersRemovedOnVirtualHostStop.

@Test
public void testLoggersRemovedOnVirtualHostStop() {
    VirtualHostLogger logger = createVirtualHostLogger();
    ((AbstractConfiguredObject<?>) _virtualHost).stop();
    Appender<ILoggingEvent> appender = ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).getAppender(logger.getName());
    assertNull("Appender was not deleted", appender);
}
Also used : AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) EventLogger(org.apache.qpid.server.logging.EventLogger) Logger(org.slf4j.Logger) VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) Test(org.junit.Test)

Example 3 with VirtualHostLogger

use of org.apache.qpid.server.model.VirtualHostLogger in project qpid-broker-j by apache.

the class VirtualHostLoggerTest method testAddLoggerWithRollDailyOn.

@Test
public void testAddLoggerWithRollDailyOn() {
    VirtualHostLogger logger = createVirtualHostLogger(Collections.<String, Object>singletonMap("rollDaily", true));
    assertTrue("Unexpected logger created " + logger, logger instanceof VirtualHostFileLogger);
    assertEquals("Unexpected log file", _logFile.getPath(), ((VirtualHostFileLogger<?>) logger).getFileName());
    assertEquals("Unexpected state on creation", State.ACTIVE, logger.getState());
    assertTrue("Log file does not exists", _logFile.exists());
    Appender<ILoggingEvent> appender = ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).getAppender(logger.getName());
    assertTrue("Appender was not started", appender.isStarted());
}
Also used : VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) EventLogger(org.apache.qpid.server.logging.EventLogger) Logger(org.slf4j.Logger) VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) Test(org.junit.Test)

Example 4 with VirtualHostLogger

use of org.apache.qpid.server.model.VirtualHostLogger in project qpid-broker-j by apache.

the class VirtualHostLoggerTest method testAddLoggerWithDefaultSettings.

@Test
public void testAddLoggerWithDefaultSettings() {
    VirtualHostLogger logger = createVirtualHostLogger();
    assertTrue("Unexpected logger created " + logger, logger instanceof VirtualHostFileLogger);
    assertEquals("Unexpected log file", _logFile.getPath(), ((VirtualHostFileLogger<?>) logger).getFileName());
    assertEquals("Unexpected state on creation", State.ACTIVE, logger.getState());
    assertTrue("Log file does not exists", _logFile.exists());
    Appender<ILoggingEvent> appender = ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).getAppender(logger.getName());
    assertTrue("Appender was not started", appender.isStarted());
}
Also used : VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) EventLogger(org.apache.qpid.server.logging.EventLogger) Logger(org.slf4j.Logger) VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) Test(org.junit.Test)

Example 5 with VirtualHostLogger

use of org.apache.qpid.server.model.VirtualHostLogger in project qpid-broker-j by apache.

the class VirtualHostLoggerTest method testDeleteLogger.

@Test
public void testDeleteLogger() {
    VirtualHostLogger logger = createVirtualHostLogger();
    assertEquals("Unexpected state on creation", State.ACTIVE, logger.getState());
    Appender<ILoggingEvent> appender = ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).getAppender(logger.getName());
    assertTrue("Appender is not started", appender.isStarted());
    logger.delete();
    appender = ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).getAppender(logger.getName());
    assertNull("Appender should be detached on logger deletion", appender);
}
Also used : VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) EventLogger(org.apache.qpid.server.logging.EventLogger) Logger(org.slf4j.Logger) VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) Test(org.junit.Test)

Aggregations

ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)5 EventLogger (org.apache.qpid.server.logging.EventLogger)5 VirtualHostLogger (org.apache.qpid.server.model.VirtualHostLogger)5 Test (org.junit.Test)5 Logger (org.slf4j.Logger)5 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1