Search in sources :

Example 36 with Logger

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

the class GetAgreementsTests method main.

public static void main(String... args) throws Exception {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.INFO);
    // condense test cases
    // read datasets (input and expected output)
    // modify input, removing graphs and triples until the test breaks
    String outputPath = "src/test/resources/won/utils/agreement/condensed/";
    String inputPath = "src/test/resources/won/utils/agreement/input/";
    Stream<Path> resources = Files.list(Paths.get(inputPath));
    resources.forEach(resource -> {
        try {
            System.out.println("trying to condense: " + resource.toAbsolutePath().toString());
            condenseTestCaseByQuery(resource, outputPath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    });
}
Also used : Path(java.nio.file.Path) Logger(ch.qos.logback.classic.Logger)

Example 37 with Logger

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

the class GetAgreementsTests 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 38 with Logger

use of ch.qos.logback.classic.Logger in project coffeenet-starter by coffeenet.

the class CoffeeNetLoggingAutoConfigurationDevelopmentFileGelfTest method integration.

@Test
public void integration() {
    final Logger logger = (Logger) LoggerFactory.getLogger(ROOT_LOGGER_NAME);
    assertThat(logger.getAppender("CONSOLE"), is(nullValue()));
    assertThat(logger.getAppender("COFFEENET-FILE"), is(instanceOf(RollingFileAppender.class)));
    assertThat(logger.getAppender("COFFEENET-GELF"), is(instanceOf(GelfAppender.class)));
}
Also used : Logger(ch.qos.logback.classic.Logger) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 39 with Logger

use of ch.qos.logback.classic.Logger in project coffeenet-starter by coffeenet.

the class CoffeeNetLoggingAutoConfigurationIntegrationOnlyConsoleTest method integration.

@Test
public void integration() {
    final Logger logger = (Logger) LoggerFactory.getLogger(ROOT_LOGGER_NAME);
    assertThat(logger.getAppender("CONSOLE"), is(instanceOf(ConsoleAppender.class)));
    assertThat(logger.getAppender("COFFEENET-FILE"), is(nullValue()));
    assertThat(logger.getAppender("COFFEENET-GELF"), is(nullValue()));
}
Also used : Logger(ch.qos.logback.classic.Logger) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 40 with Logger

use of ch.qos.logback.classic.Logger in project coffeenet-starter by coffeenet.

the class CoffeeNetLoggingAutoConfigurationTest method integration.

@Test
public void integration() {
    final Logger logger = (Logger) LoggerFactory.getLogger(ROOT_LOGGER_NAME);
    assertThat(logger.getAppender("CONSOLE"), is(instanceOf(ConsoleAppender.class)));
    Appender<ILoggingEvent> fileAppender = logger.getAppender("COFFEENET-FILE");
    assertThat(fileAppender, is(instanceOf(RollingFileAppender.class)));
    // Check File Appender
    RollingFileAppender rollingFileAppender = (RollingFileAppender) fileAppender;
    assertThat(rollingFileAppender.getFile(), is("logs/app.log"));
    assertThat(rollingFileAppender.getName(), is("COFFEENET-FILE"));
    RollingPolicy rollingPolicy = rollingFileAppender.getRollingPolicy();
    assertThat(rollingPolicy, is(instanceOf(TimeBasedRollingPolicy.class)));
    TimeBasedRollingPolicy timeBasedRollingPolicy = (TimeBasedRollingPolicy) rollingFileAppender.getRollingPolicy();
    assertThat(timeBasedRollingPolicy.getFileNamePattern(), is("logs/app-%d{yyyy-MM-dd}.log"));
    PatternLayoutEncoder encoder = (PatternLayoutEncoder) rollingFileAppender.getEncoder();
    assertThat(encoder.getPattern(), is("%d{yyyy-MM-dd HH:mm:ss.SSS} %5p --- [%t] %-40.40logger{39} : %m%n%wEx"));
    // Check Gelf Appender
    Appender<ILoggingEvent> gelfAppender = logger.getAppender("COFFEENET-GELF");
    assertThat(gelfAppender, is(instanceOf(GelfAppender.class)));
    GelfAppender gelfAppender1 = (GelfAppender) gelfAppender;
    assertThat(gelfAppender1.getName(), is("COFFEENET-GELF"));
    assertThat(gelfAppender1.getServer(), is("localServer"));
    assertThat(gelfAppender1.getProtocol(), is("TCP"));
    assertThat(gelfAppender1.getPort(), is(1337));
    assertThat(((PatternLayout) gelfAppender1.getLayout()).getPattern(), is("%m"));
    assertThat(gelfAppender1.getAdditionalFields(), hasEntry("environment", "test"));
    assertThat(gelfAppender1.getAdditionalFields(), hasEntry("application", "CoffeeNetApplication"));
}
Also used : PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder) RollingFileAppender(ch.qos.logback.core.rolling.RollingFileAppender) GelfAppender(de.appelgriepsch.logback.GelfAppender) RollingPolicy(ch.qos.logback.core.rolling.RollingPolicy) TimeBasedRollingPolicy(ch.qos.logback.core.rolling.TimeBasedRollingPolicy) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) TimeBasedRollingPolicy(ch.qos.logback.core.rolling.TimeBasedRollingPolicy) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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