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

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

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

RollingFileAppender.setTriggeringPolicy介绍

暂无

代码示例

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

@Override
 public FileAppender<ILoggingEvent> createAppender(String appenderName) {
  RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<>();
  appender.setContext(context);
  appender.setName(appenderName);
  String filePath = new File(logsDir, filenamePrefix + ".log").getAbsolutePath();
  appender.setFile(filePath);
  SizeBasedTriggeringPolicy<ILoggingEvent> trigger = new SizeBasedTriggeringPolicy<>();
  trigger.setMaxFileSize(FileSize.valueOf(size));
  trigger.setContext(context);
  trigger.start();
  appender.setTriggeringPolicy(trigger);
  FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
  rollingPolicy.setContext(context);
  rollingPolicy.setFileNamePattern(StringUtils.replace(filePath, filenamePrefix + ".log", filenamePrefix + ".%i.log"));
  rollingPolicy.setMinIndex(1);
  rollingPolicy.setMaxIndex(maxFiles);
  rollingPolicy.setParent(appender);
  rollingPolicy.start();
  appender.setRollingPolicy(rollingPolicy);
  return appender;
 }
}

代码示例来源:origin: kaaproject/kaa

rfAppender.setTriggeringPolicy(triggeringPolicy);
rfAppender.start();

代码示例来源:origin: jmxtrans/jmxtrans

protected Appender buildAppender(String loggerName, String fileStr) {
  final RollingFileAppender appender = new RollingFileAppender();
  appender.setName(loggerName + "RollingFile");
  appender.setContext(loggerContext);
  appender.setImmediateFlush(true);
  appender.setBufferSize(new FileSize(LOG_IO_BUFFER_SIZE_BYTES));
  appender.setFile(fileStr);
  appender.setEncoder(buildEncoder());
  TriggeringPolicy triggeringPolicy = buildTriggeringPolicy();
  if (triggeringPolicy != null) {
    appender.setTriggeringPolicy(triggeringPolicy);
  }
  appender.setRollingPolicy(buildRollingPolicy(appender, fileStr));
  appender.start();
  return appender;
}

代码示例来源:origin: stackoverflow.com

rfAppender.setTriggeringPolicy(triggeringPolicy);

代码示例来源:origin: dropwizard/dropwizard

triggeringPolicy.setContext(context);
triggeringPolicy.start();
appender.setTriggeringPolicy(triggeringPolicy);
  triggeringPolicy.setContext(context);
  triggeringPolicy.setTimeBasedRollingPolicy(rollingPolicy);
  appender.setTriggeringPolicy(triggeringPolicy);
} else {

代码示例来源:origin: alibaba/nacos

appender.setTriggeringPolicy(triggerPolicy);

代码示例来源:origin: alibaba/nacos

appender.setTriggeringPolicy(triggerPolicy);

代码示例来源:origin: com.github.tornaia/aott-desktop-client-core

@Bean
  public RollingFileAppender<ILoggingEvent> fileAppender(SessionSettingsProvider sessionSettingsProvider, LoggerContext loggerContext, PatternLayoutEncoder encoder, FixedWindowRollingPolicy fixedWindowRollingPolicy, SizeBasedTriggeringPolicy<ILoggingEvent> sizeBasedTriggeringPolicy) {
    RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<>();
    rollingFileAppender.setContext(loggerContext);
    rollingFileAppender.setEncoder(encoder);
    rollingFileAppender.setFile(sessionSettingsProvider.getLogsDirectory().resolve("desktop-client.log").toString());
    rollingFileAppender.setRollingPolicy(fixedWindowRollingPolicy);
    rollingFileAppender.setTriggeringPolicy(sizeBasedTriggeringPolicy);

    fixedWindowRollingPolicy.setParent(rollingFileAppender);

    return rollingFileAppender;
  }
}

代码示例来源:origin: documents4j/documents4j

private static OutputStreamAppender<ILoggingEvent> configureFileLogging(File logFile, LoggerContext loggerContext) {
  RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<ILoggingEvent>();
  rollingFileAppender.setFile(logFile.getAbsolutePath());
  rollingFileAppender.setName("com.documents4j.logger.client.file");
  rollingFileAppender.setContext(loggerContext);
  FixedWindowRollingPolicy fixedWindowRollingPolicy = new FixedWindowRollingPolicy();
  fixedWindowRollingPolicy.setFileNamePattern(logFile.getAbsolutePath() + ".%i.gz");
  fixedWindowRollingPolicy.setMaxIndex(LogDescription.MAXIMUM_LOG_HISTORY_INDEX);
  fixedWindowRollingPolicy.setContext(loggerContext);
  fixedWindowRollingPolicy.setParent(rollingFileAppender);
  SizeBasedTriggeringPolicy<ILoggingEvent> sizeBasedTriggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>();
  sizeBasedTriggeringPolicy.setMaxFileSize(LogDescription.MAXIMUM_LOG_FILE_SIZE);
  sizeBasedTriggeringPolicy.setContext(loggerContext);
  rollingFileAppender.setRollingPolicy(fixedWindowRollingPolicy);
  rollingFileAppender.setTriggeringPolicy(sizeBasedTriggeringPolicy);
  sizeBasedTriggeringPolicy.start();
  fixedWindowRollingPolicy.start();
  System.out.println("Logging: The log is written to " + logFile);
  return rollingFileAppender;
}

代码示例来源:origin: org.codehaus.sonar/sonar-process

@Override
 public FileAppender createAppender(String appenderName) {
  RollingFileAppender appender = new RollingFileAppender();
  appender.setContext(context);
  appender.setName(appenderName);
  String filePath = new File(logsDir, filenamePrefix + ".log").getAbsolutePath();
  appender.setFile(filePath);
  SizeBasedTriggeringPolicy trigger = new SizeBasedTriggeringPolicy(size);
  trigger.setContext(context);
  trigger.start();
  appender.setTriggeringPolicy(trigger);
  FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
  rollingPolicy.setContext(context);
  rollingPolicy.setFileNamePattern(StringUtils.replace(filePath, filenamePrefix + ".log", filenamePrefix + ".%i.log"));
  rollingPolicy.setMinIndex(1);
  rollingPolicy.setMaxIndex(maxFiles);
  rollingPolicy.setParent(appender);
  rollingPolicy.start();
  appender.setRollingPolicy(rollingPolicy);
  return appender;
 }
}

代码示例来源:origin: documents4j/documents4j

private static OutputStreamAppender<ILoggingEvent> configureFileLogging(File logFile, LoggerContext loggerContext) {
  RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<ILoggingEvent>();
  rollingFileAppender.setFile(logFile.getAbsolutePath());
  rollingFileAppender.setName("com.documents4j.logger.server.file");
  rollingFileAppender.setContext(loggerContext);
  FixedWindowRollingPolicy fixedWindowRollingPolicy = new FixedWindowRollingPolicy();
  fixedWindowRollingPolicy.setFileNamePattern(logFile.getAbsolutePath() + ".%i.gz");
  fixedWindowRollingPolicy.setMaxIndex(LogDescription.MAXIMUM_LOG_HISTORY_INDEX);
  fixedWindowRollingPolicy.setContext(loggerContext);
  fixedWindowRollingPolicy.setParent(rollingFileAppender);
  SizeBasedTriggeringPolicy<ILoggingEvent> sizeBasedTriggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>();
  sizeBasedTriggeringPolicy.setMaxFileSize(LogDescription.MAXIMUM_LOG_FILE_SIZE);
  sizeBasedTriggeringPolicy.setContext(loggerContext);
  rollingFileAppender.setRollingPolicy(fixedWindowRollingPolicy);
  rollingFileAppender.setTriggeringPolicy(sizeBasedTriggeringPolicy);
  sizeBasedTriggeringPolicy.start();
  fixedWindowRollingPolicy.start();
  System.out.println("Logging: The log is written to " + logFile);
  return rollingFileAppender;
}

代码示例来源:origin: dstl/baleen

trigger.start();
appender.setRollingPolicy(rolling);
appender.setTriggeringPolicy(trigger);

代码示例来源:origin: com.nhl.bootique.logback/bootique-logback

protected FileAppender<ILoggingEvent> createRollingFileAppender(Encoder<ILoggingEvent> encoder,
                                LoggerContext context,
                                RollingPolicyFactory rollingPolicy) {
  RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<>();
  appender.setFile(file);
  appender.setContext(context);
  appender.setEncoder(encoder);
  // Setup rolling policy
  RollingPolicy policy = rollingPolicy.createRollingPolicy(context);
  appender.setRollingPolicy(policy);
  policy.setParent(appender);
  // Setup triggering policy
  TriggeringPolicy<ILoggingEvent> triggeringPolicy = rollingPolicy.createTriggeringPolicy(context);
  if (triggeringPolicy != null) {
    appender.setTriggeringPolicy(triggeringPolicy);
    triggeringPolicy.start();
  }
  policy.start();
  appender.start();
  return appender;
}

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

@Test
public void testFilePropertyAfterTriggeringPolicy() {
 rfa.setContext(context);
 rfa.setTriggeringPolicy(new SizeBasedTriggeringPolicy<Object>());
 rfa.setFile("x");
 StatusChecker statusChecker = new StatusChecker(context.getStatusManager());
 statusChecker.assertContainsMatch(Status.ERROR,
     "File property must be set before any triggeringPolicy ");
}

代码示例来源:origin: org.jmxtrans/jmxtrans-output-logback

protected Appender buildAppender(String loggerName, String fileStr) {
  final RollingFileAppender appender = new RollingFileAppender();
  appender.setName(loggerName + "RollingFile");
  appender.setContext(loggerContext);
  appender.setImmediateFlush(true);
  appender.setBufferSize(new FileSize(LOG_IO_BUFFER_SIZE_BYTES));
  appender.setFile(fileStr);
  appender.setEncoder(buildEncoder());
  TriggeringPolicy triggeringPolicy = buildTriggeringPolicy();
  if (triggeringPolicy != null) {
    appender.setTriggeringPolicy(triggeringPolicy);
  }
  appender.setRollingPolicy(buildRollingPolicy(appender, fileStr));
  appender.start();
  return appender;
}

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

@Test
public void stopFixedWindowRollingPolicy() {
 rfa.setContext(context);
 rfa.setFile(CoreTestConstants.OUTPUT_DIR_PREFIX + "toto-.log");
 FixedWindowRollingPolicy fwRollingPolicy = new FixedWindowRollingPolicy();
 fwRollingPolicy.setContext(context);
 fwRollingPolicy.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "toto-%i.log.zip");
 fwRollingPolicy.setParent(rfa);
 fwRollingPolicy.start();
 SizeBasedTriggeringPolicy<Object> sbTriggeringPolicy = new SizeBasedTriggeringPolicy<Object>();
 sbTriggeringPolicy.setContext(context);
 sbTriggeringPolicy.start();
 rfa.setRollingPolicy(fwRollingPolicy);
 rfa.setTriggeringPolicy(sbTriggeringPolicy);
 rfa.start();
 StatusPrinter.print(context);
 assertTrue(fwRollingPolicy.isStarted());
 assertTrue(sbTriggeringPolicy.isStarted());
 assertTrue(rfa.isStarted());
 rfa.stop();
 assertFalse(rfa.isStarted());
 assertFalse(fwRollingPolicy.isStarted());
 assertFalse(sbTriggeringPolicy.isStarted());
}

代码示例来源:origin: SoftInstigate/restheart

rfAppender.setName("ROLLINGFILE");
rfAppender.setRollingPolicy(fwRollingPolicy);
rfAppender.setTriggeringPolicy(triggeringPolicy);
rfAppender.start();

代码示例来源:origin: com.alibaba.nacos/nacos-client

appender.setTriggeringPolicy(triggerPolicy);

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

public void setUpSizeBasedTriggeringPolicy(RollingFileAppender<Object> rfa) {
 SizeBasedTriggeringPolicy<Object> zbtp = new SizeBasedTriggeringPolicy<Object>();
 zbtp.setContext(context);
 zbtp.setMaxFileSize(FileSize.valueOf("100KB"));
 zbtp.start();
 rfa.setTriggeringPolicy(zbtp);
 FixedWindowRollingPolicy fwrp = new FixedWindowRollingPolicy();
 fwrp.setContext(context);
 fwrp.setFileNamePattern(outputDirStr + "test-%i.log");
 fwrp.setMaxIndex(20);
 fwrp.setMinIndex(0);
 fwrp.setParent(rfa);
 fwrp.start();
 rfa.setRollingPolicy(fwrp);
 rfa.start();
}

代码示例来源:origin: com.plausiblelabs.warwizard/warwizard-core

appender.setPrudent(false);
appender.setRollingPolicy(rollingPolicy);
appender.setTriggeringPolicy(triggeringPolicy);
addThresholdFilter(appender, file.getThreshold());

相关文章