Search in sources :

Example 71 with Appender

use of org.apache.log4j.Appender in project scheduling by ow2-proactive.

the class TaskLogger method getStoredLogs.

public void getStoredLogs(AppenderProvider logSink) {
    Appender appender;
    try {
        appender = logSink.getAppender();
    } catch (LogForwardingException e) {
        logger.error("Cannot create log appender.", e);
        return;
    }
    taskLogAppender.appendStoredEvents(appender);
}
Also used : Appender(org.apache.log4j.Appender) FileAppender(org.apache.log4j.FileAppender) LogForwardingException(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException)

Example 72 with Appender

use of org.apache.log4j.Appender in project scheduling by ow2-proactive.

the class SchedulerStateRestLiveLogsTest method testLiveLogs_AvailableAndDelete.

@Test
public void testLiveLogs_AvailableAndDelete() throws Exception {
    String firstJobId = "42";
    assertEquals(-1, client.getLiveLogJobAvailable(sessionId, "42"));
    String logs = client.getLiveLogJob(sessionId, firstJobId);
    Appender appender = verifyListenAndGetAppender("42");
    assertEquals(0, client.getLiveLogJobAvailable(sessionId, "42"));
    assertTrue(logs.isEmpty());
    appender.doAppend(createLoggingEvent(firstJobId, "first log"));
    assertEquals(1, client.getLiveLogJobAvailable(sessionId, "42"));
    assertTrue(client.deleteLiveLogJob(sessionId, "42"));
    assertEquals(-1, client.getLiveLogJobAvailable(sessionId, "42"));
    // will be lost
    appender.doAppend(createLoggingEvent(firstJobId, "second log"));
    logs = client.getLiveLogJob(sessionId, firstJobId);
    assertTrue(logs.isEmpty());
    appender.doAppend(createLoggingEvent(firstJobId, "other log"));
    appender.doAppend(createLoggingEvent(firstJobId, "more log"));
    assertEquals(2, client.getLiveLogJobAvailable(sessionId, "42"));
    logs = client.getLiveLogJob(sessionId, firstJobId);
    assertThat(logs, not(containsString("first log")));
    assertThat(logs, containsString("other log"));
    assertThat(logs, containsString("more log"));
    assertEquals(0, client.getLiveLogJobAvailable(sessionId, "42"));
    logs = client.getLiveLogJob(sessionId, firstJobId);
    assertTrue(logs.isEmpty());
}
Also used : Appender(org.apache.log4j.Appender) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 73 with Appender

use of org.apache.log4j.Appender in project scheduling by ow2-proactive.

the class SchedulerStateRestLiveLogsTest method testLiveLogs_TwoJobsAtTheSameTime.

@Test
public void testLiveLogs_TwoJobsAtTheSameTime() throws Exception {
    String firstJobId = "42";
    String secondJobId = "43";
    String firstJobLogs = client.getLiveLogJob(sessionId, firstJobId);
    Appender firstAppender = verifyListenAndGetAppender(firstJobId);
    String secondJobLogs = client.getLiveLogJob(sessionId, secondJobId);
    Appender secondAppender = verifyListenAndGetAppender(secondJobId);
    assertTrue(firstJobLogs.isEmpty());
    assertTrue(secondJobLogs.isEmpty());
    firstAppender.doAppend(createLoggingEvent(firstJobId, "first job"));
    secondAppender.doAppend(createLoggingEvent(secondJobId, "second job"));
    firstJobLogs = client.getLiveLogJob(sessionId, firstJobId);
    assertThat(firstJobLogs, containsString("first job"));
    secondJobLogs = client.getLiveLogJob(sessionId, secondJobId);
    assertThat(secondJobLogs, containsString("second job"));
}
Also used : Appender(org.apache.log4j.Appender) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Aggregations

Appender (org.apache.log4j.Appender)73 FileAppender (org.apache.log4j.FileAppender)24 Logger (org.apache.log4j.Logger)20 File (java.io.File)12 ConsoleAppender (org.apache.log4j.ConsoleAppender)11 RollingFileAppender (org.apache.log4j.RollingFileAppender)11 WriterAppender (org.apache.log4j.WriterAppender)11 NullAppender (org.apache.log4j.varia.NullAppender)11 PatternLayout (org.apache.log4j.PatternLayout)9 Log4JLogger (org.apache.commons.logging.impl.Log4JLogger)8 Enumeration (java.util.Enumeration)7 Test (org.junit.Test)7 IOException (java.io.IOException)6 AsyncAppender (org.apache.log4j.AsyncAppender)6 Layout (org.apache.log4j.Layout)6 LogfileAppender (org.knime.core.util.LogfileAppender)6 DailyRollingFileAppender (org.apache.log4j.DailyRollingFileAppender)5 Filter (org.apache.log4j.spi.Filter)5 LevelRangeFilter (org.apache.log4j.varia.LevelRangeFilter)5 ActiveDbAppender (com.axway.ats.log.appenders.ActiveDbAppender)4