ch.qos.logback.core.rolling.RollingFileAppender.doAppend()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(195)

本文整理了Java中ch.qos.logback.core.rolling.RollingFileAppender.doAppend方法的一些代码示例,展示了RollingFileAppender.doAppend的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RollingFileAppender.doAppend方法的具体详情如下:
包路径:ch.qos.logback.core.rolling.RollingFileAppender
类名称:RollingFileAppender
方法名:doAppend

RollingFileAppender.doAppend介绍

暂无

代码示例

代码示例来源:origin: com.teradata.airlift/http-server

@Override
public void log(Request request, Response response)
{
  long currentTime = currentTimeMillisProvider.getCurrentTimeMillis();
  HttpRequestEvent event = createHttpRequestEvent(request, response, traceTokenManager, currentTime);
  fileAppender.doAppend(event);
  eventClient.post(event);
}

代码示例来源:origin: tony19/logback-android

public void run() {
  while (!isDone()) {
   counter++;
   rfa.doAppend(id + " " + counter);
   if ((counter % 64 == 0) && withInducedDelay) {
    try {
     Thread.sleep(10);
    } catch (InterruptedException e) {
    }
   }
  }
 }
}

代码示例来源:origin: com.teradata.airlift/log-manager

@Override
public void publish(LogRecord record)
{
  if (!isLoggable(record)) {
    return;
  }
  String message;
  try {
    message = getFormatter().format(record);
  }
  catch (Exception e) {
    // catch any exception to assure logging always works
    reportError(null, e, FORMAT_FAILURE);
    return;
  }
  try {
    fileAppender.doAppend(message);
  }
  catch (Exception e) {
    // catch any exception to assure logging always works
    reportError(null, e, WRITE_FAILURE);
  }
}

代码示例来源:origin: tony19/logback-android

rfa.doAppend(sb.toString());
addExpectedFileNamedIfItsTime_ByDate(fileNamePatternStr);
incCurrentTime(singleTickDuration);

代码示例来源:origin: tony19/logback-android

private long logOverMultiplePeriods(ConfigParameters cp) {
  buildRollingFileAppender(cp);
  final int ticksPerPeriod = 216;
  int runLength = cp.simulatedNumberOfPeriods * ticksPerPeriod;
  int startInactivityIndex = cp.startInactivity * ticksPerPeriod;
  int endInactivityIndex = startInactivityIndex + cp.numInactivityPeriods * ticksPerPeriod;
  long tickDuration = cp.periodDurationInMillis / ticksPerPeriod;

  for (int i = 0; i <= runLength; i++) {
   if (i < startInactivityIndex || i > endInactivityIndex) {
    Date currentDate = new Date(tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime());
    StringBuilder sb = new StringBuilder("Hello");
    String currentDateStr = currentDate.toString();
    String iAsString = Integer.toString(i);
    sb.append(currentDateStr);
    SpacePadder.spacePad(sb, 66 + (3 - iAsString.length() - currentDateStr.length()));
    sb.append(iAsString);
    rfa.doAppend(sb.toString());
   }
   tbrp.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime() +
       tickDuration);
   add(tbrp.compressionFuture);
   add(tbrp.cleanUpFuture);
   waitForJobsToComplete();
  }

  rfa.stop();
  return tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime();
 }
}

代码示例来源:origin: tony19/logback-android

private void secondPhase(String testId, String file, String stem, String compressionSuffix, int runLength, String prefix) {
 rfa1.stop();
 if (stem != null) {
  File f = new File(file);
  f.setLastModified(currentTime);
 }
 StatusManager sm = context.getStatusManager();
 sm.add(new InfoStatus("Time when rfa1 is stopped: " + new Date(currentTime), this));
 sm.add(new InfoStatus("currentTime%1000=" + (currentTime % 1000), this));
 initRollingFileAppender(rfa2, file);
 initPolicies(rfa2, tbrp2, randomOutputDir + testId + "-%d{"
     + DATE_PATTERN_WITH_SECONDS + ", GMT}-%i.txt" + compressionSuffix, sizeThreshold, currentTime);
 for (int i = runLength; i < runLength * 2; i++) {
  incCurrentTime(100);
  tbrp2.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);
  String msg = prefix + i;
  rfa2.doAppend(msg);
  addExpectedFileNamedIfItsTime(randomOutputDir, testId, msg, compressionSuffix);
 }
}

代码示例来源:origin: tony19/logback-android

@Test
public void testFileNameWithParenthesis() {
 // if ')' is not escaped, the test throws
 // java.lang.IllegalStateException: FileNamePattern [.../program(x86)/toto-%d.log] does not contain a valid DateToken
 rfa.setContext(context);
 tbrp
     .setFileNamePattern(randomOutputDir + "program(x86)/toto-%d.log");
 tbrp.start();
 rfa.setRollingPolicy(tbrp);
 rfa.start();
 rfa.doAppend("hello");
}

代码示例来源:origin: tony19/logback-android

private void doRestart(String testId, String patternPart, boolean fileOptionIsSet, int waitDuration) {
 // change the timestamp of the currently actively file
 File activeFile = new File(rfa1.getFile());
 activeFile.setLastModified(currentTime);
 incCurrentTime(waitDuration);
 String filePatternStr = randomOutputDir + patternPart + "-%d{" + DATE_PATTERN_WITH_SECONDS + ", GMT}";
 String fileName = fileOptionIsSet ? testId2FileName(testId) : null;
 initRFA(rfa2, fileName);
 initTRBP(rfa2, tbrp2, filePatternStr, currentTime);
 for (int i = 0; i < 3; i++) {
  rfa2.doAppend("World---" + i);
  addExpectedFileNamedIfItsTime_ByDate(filePatternStr);
  incCurrentTime(400);
  tbrp2.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);
  add(tbrp2.compressionFuture);
  add(tbrp2.cleanUpFuture);
 }
 rfa2.stop();
}

代码示例来源:origin: tony19/logback-android

void generic(String testName, String fileName, String filenamePattern, List<String> expectedFilenameList) throws InterruptedException, IOException {
 rfa.setName("ROLLING");
 initRFA(randomOutputDir + fileName);
 sizeBasedTriggeringPolicy.setMaxFileSize(new FileSize(100));
 fwrp.setMinIndex(0);
 fwrp.setFileNamePattern(randomOutputDir + filenamePattern);
 rfa.triggeringPolicy = sizeBasedTriggeringPolicy;
 rfa.rollingPolicy = fwrp;
 fwrp.start();
 sizeBasedTriggeringPolicy.start();
 rfa.start();
 int runLength = 40;
 String prefix = "hello";
 for (int i = 0; i < runLength; i++){
  Thread.sleep(10);
  rfa.doAppend(prefix + i);
 }
 rfa.stop();
 existenceCheck(expectedFilenameList);
 reverseSortedContentCheck(randomOutputDir, runLength, prefix);
}

代码示例来源:origin: tony19/logback-android

rfa1.doAppend(msg);
addExpectedFileNamedIfItsTime(randomOutputDir, testId, msg, compressionSuffix);
incCurrentTime(20);

代码示例来源:origin: tony19/logback-android

private void genericTest(String testId, String patternPrefix, String compressionSuffix, boolean fileOptionIsSet, int waitDuration) throws IOException {
 String fileName = fileOptionIsSet ? testId2FileName(testId) : null;
 initRFA(rfa1, fileName);
 String fileNamePatternStr = randomOutputDir + patternPrefix + "-%d{" + DATE_PATTERN_WITH_SECONDS + ", GMT}" + compressionSuffix;
 initTRBP(rfa1, tbrp1, fileNamePatternStr, currentTime);
 // compute the current filename
 addExpectedFileName_ByDate(fileNamePatternStr, getMillisOfCurrentPeriodsStart());
 incCurrentTime(1100);
 tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);
 for (int i = 0; i < 3; i++) {
  rfa1.doAppend("Hello---" + i);
  addExpectedFileNamedIfItsTime_ByDate(fileNamePatternStr);
  incCurrentTime(500);
  tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);
  add(tbrp1.compressionFuture);
  add(tbrp1.cleanUpFuture);
 }
 rfa1.stop();
 waitForJobsToComplete();
 if (waitDuration != NO_RESTART) {
  doRestart(testId, patternPrefix, fileOptionIsSet, waitDuration);
 }
 waitForJobsToComplete();
 massageExpectedFilesToCorresponToCurrentTarget(fileName, fileOptionIsSet);
 StatusPrinter.print(context);
 rolloverChecker.check(expectedFilenameList);
}

相关文章