Search in sources :

Example 1 with ListAppender

use of ch.qos.logback.core.read.ListAppender in project jackrabbit-oak by apache.

the class PropertyIndexTest method traversalWarning.

@Test
public void traversalWarning() throws Exception {
    ListAppender appender = createAndRegisterAppender();
    int testDataSize = ContentMirrorStoreStrategy.TRAVERSING_WARN;
    NodeState indexed = createTestData(testDataSize);
    assertEquals(testDataSize, getResultSize(indexed, "foo", "bar"));
    assertFalse(appender.list.isEmpty());
    appender.list.clear();
    testDataSize = 100;
    indexed = createTestData(100);
    assertEquals(testDataSize, getResultSize(indexed, "foo", "bar"));
    assertTrue("Warning should not be logged for traversing " + testDataSize, appender.list.isEmpty());
    deregisterAppender(appender);
}
Also used : EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ListAppender(ch.qos.logback.core.read.ListAppender) Test(org.junit.Test)

Example 2 with ListAppender

use of ch.qos.logback.core.read.ListAppender in project qpid-broker-j by apache.

the class BrokerLoggerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    _taskExecutor = new TaskExecutorImpl();
    _taskExecutor.start();
    _loggerAppender = new ListAppender<>();
    _loggerAppender.setName(APPENDER_NAME);
    Model model = BrokerModel.getInstance();
    _broker = mock(Broker.class);
    when(_broker.getCategoryClass()).thenReturn(Broker.class);
    when(_broker.getTypeClass()).thenReturn(Broker.class);
    when(_broker.getModel()).thenReturn(model);
    when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
    doReturn(Broker.class).when(_broker).getCategoryClass();
    Map<String, Object> attributes = new HashMap<>();
    attributes.put("name", APPENDER_NAME);
    _brokerLogger = new AbstractBrokerLogger(attributes, _broker) {

        @Override
        public Appender<ILoggingEvent> createAppenderInstance(Context context) {
            return _loggerAppender;
        }
    };
    _brokerLogger.open();
}
Also used : Context(ch.qos.logback.core.Context) Appender(ch.qos.logback.core.Appender) ListAppender(ch.qos.logback.core.read.ListAppender) TaskExecutorImpl(org.apache.qpid.server.configuration.updater.TaskExecutorImpl) Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) AbstractBrokerLogger(org.apache.qpid.server.logging.logback.AbstractBrokerLogger) BrokerModel(org.apache.qpid.server.model.BrokerModel) Model(org.apache.qpid.server.model.Model) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 3 with ListAppender

use of ch.qos.logback.core.read.ListAppender in project qpid-broker-j by apache.

the class LoggerTestHelper method createAndRegisterAppender.

public static ListAppender createAndRegisterAppender(String appenderName) {
    ListAppender appender = new ListAppender();
    appender.setName(appenderName);
    ROOT_LOGGER.addAppender(appender);
    appender.start();
    return appender;
}
Also used : ListAppender(ch.qos.logback.core.read.ListAppender)

Example 4 with ListAppender

use of ch.qos.logback.core.read.ListAppender in project nifi by apache.

the class TestFileSystemRepository method testMinimalArchiveCleanupIntervalHonoredAndLogged.

@Test
public void testMinimalArchiveCleanupIntervalHonoredAndLogged() throws Exception {
    // We are going to construct our own repository using different properties, so
    // we need to shutdown the existing one.
    shutdown();
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    ListAppender<ILoggingEvent> testAppender = new ListAppender<>();
    testAppender.setName("Test");
    testAppender.start();
    root.addAppender(testAppender);
    final Map<String, String> addProps = new HashMap<>();
    addProps.put(NiFiProperties.CONTENT_ARCHIVE_CLEANUP_FREQUENCY, "1 millis");
    final NiFiProperties localProps = NiFiProperties.createBasicNiFiProperties(null, addProps);
    repository = new FileSystemRepository(localProps);
    repository.initialize(new StandardResourceClaimManager());
    repository.purge();
    boolean messageFound = false;
    String message = "The value of nifi.content.repository.archive.cleanup.frequency property " + "is set to '1 millis' which is below the allowed minimum of 1 second (1000 milliseconds). " + "Minimum value of 1 sec will be used as scheduling interval for archive cleanup task.";
    // keyword guards testAppender.list. Since we are accessing testAppender.list, we must do so in a thread-safe manner.
    synchronized (testAppender) {
        for (ILoggingEvent event : testAppender.list) {
            String actualMessage = event.getFormattedMessage();
            if (actualMessage.equals(message)) {
                assertEquals(event.getLevel(), Level.WARN);
                messageFound = true;
                break;
            }
        }
    }
    assertTrue(messageFound);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) HashMap(java.util.HashMap) ListAppender(ch.qos.logback.core.read.ListAppender) StandardResourceClaimManager(org.apache.nifi.controller.repository.claim.StandardResourceClaimManager) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) Test(org.junit.Test)

Example 5 with ListAppender

use of ch.qos.logback.core.read.ListAppender in project jackrabbit-oak by apache.

the class PropertyIndexTest method createAndRegisterAppender.

private ListAppender createAndRegisterAppender() {
    TraversingWarningFilter filter = new TraversingWarningFilter();
    filter.start();
    ListAppender appender = new ListAppender<ILoggingEvent>();
    appender.setContext(getContext());
    appender.setName("TestLogCollector");
    appender.addFilter(filter);
    appender.start();
    rootLogger().addAppender(appender);
    return appender;
}
Also used : ListAppender(ch.qos.logback.core.read.ListAppender)

Aggregations

ListAppender (ch.qos.logback.core.read.ListAppender)6 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 Logger (ch.qos.logback.classic.Logger)1 Appender (ch.qos.logback.core.Appender)1 Context (ch.qos.logback.core.Context)1 FilterReply (ch.qos.logback.core.spi.FilterReply)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1 StandardResourceClaimManager (org.apache.nifi.controller.repository.claim.StandardResourceClaimManager)1 NiFiProperties (org.apache.nifi.util.NiFiProperties)1 TaskExecutorImpl (org.apache.qpid.server.configuration.updater.TaskExecutorImpl)1 EventLogger (org.apache.qpid.server.logging.EventLogger)1 AbstractBrokerLogger (org.apache.qpid.server.logging.logback.AbstractBrokerLogger)1 Broker (org.apache.qpid.server.model.Broker)1 BrokerModel (org.apache.qpid.server.model.BrokerModel)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 Model (org.apache.qpid.server.model.Model)1