当前位置: 首页>>代码示例>>Java>>正文


Java Appender.doAppend方法代码示例

本文整理汇总了Java中org.apache.log4j.Appender.doAppend方法的典型用法代码示例。如果您正苦于以下问题:Java Appender.doAppend方法的具体用法?Java Appender.doAppend怎么用?Java Appender.doAppend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.log4j.Appender的用法示例。


在下文中一共展示了Appender.doAppend方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLiveLogs_TwoJobsAtTheSameTime

import org.apache.log4j.Appender; //导入方法依赖的package包/类
@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"));
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:24,代码来源:SchedulerStateRestLiveLogsTest.java

示例2: flushTaskLogs

import org.apache.log4j.Appender; //导入方法依赖的package包/类
private void flushTaskLogs(TaskResult tr, Appender a, JobId jobId) {
    // if taskResult is not awaited, task is terminated
    TaskLogs logs = tr.getOutput();
    if (logs instanceof Log4JTaskLogs) {
        for (LoggingEvent le : ((Log4JTaskLogs) logs).getAllEvents()) {
            // write into socket appender directly to avoid double lines on other listeners
            a.doAppend(le);
        }
    } else {
        a.doAppend(createLoggingEvent(jobId, logs.getStdoutLogs(false), Level.INFO));
        a.doAppend(createLoggingEvent(jobId, logs.getStderrLogs(false), Level.DEBUG));
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:14,代码来源:EnabledListenJobLogsSupport.java

示例3: testLiveLogs_OutputRemovedAtEachCall

import org.apache.log4j.Appender; //导入方法依赖的package包/类
@Test
public void testLiveLogs_OutputRemovedAtEachCall() throws Exception {

    String firstJobId = "42";

    String firstJobLogs = client.getLiveLogJob(sessionId, firstJobId);

    Appender appender = verifyListenAndGetAppender("42");

    assertTrue(firstJobLogs.isEmpty());

    appender.doAppend(createLoggingEvent(firstJobId, "first log"));

    firstJobLogs = client.getLiveLogJob(sessionId, firstJobId);
    assertThat(firstJobLogs, containsString("first log"));

    appender.doAppend(createLoggingEvent(firstJobId, "other log"));

    firstJobLogs = client.getLiveLogJob(sessionId, firstJobId);
    assertThat(firstJobLogs, not(containsString("first log")));
    assertThat(firstJobLogs, containsString("other log"));

    firstJobLogs = client.getLiveLogJob(sessionId, firstJobId);
    assertTrue(firstJobLogs.isEmpty());
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:26,代码来源:SchedulerStateRestLiveLogsTest.java

示例4: appendStoredEvents

import org.apache.log4j.Appender; //导入方法依赖的package包/类
/**
 * Append stored events to the given appender.
 */
public synchronized void appendStoredEvents(Appender appender) {
    for (LoggingEvent e : this.storage) {
        appender.doAppend(e);
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:9,代码来源:AsyncAppenderWithStorage.java

示例5: testLiveLogs_AvailableAndDelete

import org.apache.log4j.Appender; //导入方法依赖的package包/类
@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());
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:41,代码来源:SchedulerStateRestLiveLogsTest.java


注:本文中的org.apache.log4j.Appender.doAppend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。