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

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

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

RollingFileAppender.getTriggeringPolicy介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

@Test
public void createRollingPolicy_defaults() {
 LoggerContext ctx = underTest.getRootContext();
 LogbackHelper.RollingPolicy policy = underTest.createRollingPolicy(ctx, props, "sonar");
 FileAppender appender = policy.createAppender("SONAR_FILE");
 assertThat(appender).isInstanceOf(RollingFileAppender.class);
 // max 5 daily files
 RollingFileAppender fileAppender = (RollingFileAppender) appender;
 TimeBasedRollingPolicy triggeringPolicy = (TimeBasedRollingPolicy) fileAppender.getTriggeringPolicy();
 assertThat(triggeringPolicy.getMaxHistory()).isEqualTo(7);
 assertThat(triggeringPolicy.getFileNamePattern()).endsWith("sonar.%d{yyyy-MM-dd}.log");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void createRollingPolicy_time() {
 props.set("sonar.log.rollingPolicy", "time:yyyy-MM");
 props.set("sonar.log.maxFiles", "20");
 LoggerContext ctx = underTest.getRootContext();
 LogbackHelper.RollingPolicy policy = underTest.createRollingPolicy(ctx, props, "sonar");
 RollingFileAppender appender = (RollingFileAppender) policy.createAppender("SONAR_FILE");
 // max 5 monthly files
 TimeBasedRollingPolicy triggeringPolicy = (TimeBasedRollingPolicy) appender.getTriggeringPolicy();
 assertThat(triggeringPolicy.getMaxHistory()).isEqualTo(20);
 assertThat(triggeringPolicy.getFileNamePattern()).endsWith("sonar.%d{yyyy-MM}.log");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void createRollingPolicy_size() throws Exception {
 props.set("sonar.log.rollingPolicy", "size:1MB");
 props.set("sonar.log.maxFiles", "20");
 LoggerContext ctx = underTest.getRootContext();
 LogbackHelper.RollingPolicy policy = underTest.createRollingPolicy(ctx, props, "sonar");
 Appender appender = policy.createAppender("SONAR_FILE");
 assertThat(appender).isInstanceOf(RollingFileAppender.class);
 // max 20 files of 1Mb
 RollingFileAppender fileAppender = (RollingFileAppender) appender;
 FixedWindowRollingPolicy rollingPolicy = (FixedWindowRollingPolicy) fileAppender.getRollingPolicy();
 assertThat(rollingPolicy.getMaxIndex()).isEqualTo(20);
 assertThat(rollingPolicy.getFileNamePattern()).endsWith("sonar.%i.log");
 SizeBasedTriggeringPolicy triggeringPolicy = (SizeBasedTriggeringPolicy) fileAppender.getTriggeringPolicy();
 FileSize maxFileSize = (FileSize) FieldUtils.readField(triggeringPolicy, "maxFileSize", true);
 assertThat(maxFileSize.getSize()).isEqualTo(1024L * 1024);
}

代码示例来源:origin: org.opendaylight.controller/logback-config

.getTriggeringPolicy();
app.setMaxFileSize(triggeringPolicy.getMaxFileSize());
app.setName(rollingApp.getName());

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

.getTriggeringPolicy();
TimeBasedFileNamingAndTriggeringPolicy tbnatp = tprp
    .getTimeBasedFileNamingAndTriggeringPolicy();

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

@Test
public void basic() throws Exception {
 String testId = "basic";
 lc.putProperty("testId", testId);
 loadConfig(ClassicTestConstants.JORAN_INPUT_PREFIX + "rolling/" + testId
     + ".xml");
 statusChecker.assertIsErrorFree();
 Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
 expectedFilenameList.add(randomOutputDir + "z" + testId);
 RollingFileAppender<ILoggingEvent> rfa = (RollingFileAppender<ILoggingEvent>) root
     .getAppender("ROLLING");
 TimeBasedRollingPolicy tprp = (TimeBasedRollingPolicy<ILoggingEvent>) rfa
     .getTriggeringPolicy();
 TimeBasedFileNamingAndTriggeringPolicy tbnatp = tprp
     .getTimeBasedFileNamingAndTriggeringPolicy();
 String prefix = "Hello---";
 int runLength = 4;
 for (int i = 0; i < runLength; i++) {
  logger.debug(prefix + i);
  addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
  incCurrentTime(500);
  tbnatp.setCurrentTime(currentTime);
 }
 existenceCheck(expectedFilenameList);
 sortedContentCheck(randomOutputDir, runLength, prefix);
}

相关文章