Search in sources :

Example 26 with Logger

use of ch.qos.logback.classic.Logger 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 27 with Logger

use of ch.qos.logback.classic.Logger in project webofneeds by researchstudio-sat.

the class AllAcceptsTest method setLogLevel.

@BeforeClass
public static void setLogLevel() {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.INFO);
}
Also used : Logger(ch.qos.logback.classic.Logger) BeforeClass(org.junit.BeforeClass)

Example 28 with Logger

use of ch.qos.logback.classic.Logger in project webofneeds by researchstudio-sat.

the class PendingProposesTest method setLogLevel.

@BeforeClass
public static void setLogLevel() {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.INFO);
}
Also used : Logger(ch.qos.logback.classic.Logger) BeforeClass(org.junit.BeforeClass)

Example 29 with Logger

use of ch.qos.logback.classic.Logger in project webofneeds by researchstudio-sat.

the class PendingProposesToCancelTest method setLogLevel.

@BeforeClass
public static void setLogLevel() {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.INFO);
}
Also used : Logger(ch.qos.logback.classic.Logger) BeforeClass(org.junit.BeforeClass)

Example 30 with Logger

use of ch.qos.logback.classic.Logger in project webofneeds by researchstudio-sat.

the class ProposalTest method setLogLevel.

@BeforeClass
public static void setLogLevel() {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.INFO);
}
Also used : Logger(ch.qos.logback.classic.Logger) BeforeClass(org.junit.BeforeClass)

Aggregations

Logger (ch.qos.logback.classic.Logger)339 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)90 LoggerContext (ch.qos.logback.classic.LoggerContext)86 Test (org.junit.Test)78 Appender (ch.qos.logback.core.Appender)30 BeforeClass (org.junit.BeforeClass)28 FileAppender (ch.qos.logback.core.FileAppender)27 Test (org.junit.jupiter.api.Test)27 ConsoleAppender (ch.qos.logback.core.ConsoleAppender)22 File (java.io.File)21 PatternLayoutEncoder (ch.qos.logback.classic.encoder.PatternLayoutEncoder)20 Level (ch.qos.logback.classic.Level)18 ListAppender (ch.qos.logback.core.read.ListAppender)14 RollingFileAppender (ch.qos.logback.core.rolling.RollingFileAppender)12 ArrayList (java.util.ArrayList)11 Before (org.junit.Before)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 Map (java.util.Map)10 AsyncLoggingEventAppenderFactory (io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory)9 DropwizardLayoutFactory (io.dropwizard.logging.layout.DropwizardLayoutFactory)8