本文整理汇总了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"));
}
示例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));
}
}
示例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());
}
示例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);
}
}
示例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());
}