ch.qos.logback.core.util.FileSize.valueOf()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(333)

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

FileSize.valueOf介绍

暂无

代码示例

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

/**
   * logback 1.1.8开始不再支持setMaxFileSize(String)方法
   */
  protected void setMaxFileSize(Object policy, String size) {
    try {
      try {
        Method setMaxFileSizeMethod = policy.getClass().getDeclaredMethod("setMaxFileSize", String.class);
        setMaxFileSizeMethod.invoke(policy, size);
      } catch (NoSuchMethodException e) {
        Method setMaxFileSizeMethod = policy.getClass().getDeclaredMethod("setMaxFileSize", FileSize.class);
        setMaxFileSizeMethod.invoke(policy, FileSize.valueOf(size));
      }
    } catch (Throwable t) {
      throw new RuntimeException("Failed to setMaxFileSize", t);
    }
  }
}

代码示例来源:origin: org.springframework.boot/spring-boot

private void setMaxFileSize(
    SizeAndTimeBasedRollingPolicy<ILoggingEvent> rollingPolicy,
    String maxFileSize) {
  try {
    rollingPolicy.setMaxFileSize(FileSize.valueOf(maxFileSize));
  }
  catch (NoSuchMethodError ex) {
    // Logback < 1.1.8 used String configuration
    Method method = ReflectionUtils.findMethod(
        SizeAndTimeBasedRollingPolicy.class, "setMaxFileSize", String.class);
    ReflectionUtils.invokeMethod(method, rollingPolicy, maxFileSize);
  }
}

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

protected TriggeringPolicy buildTriggeringPolicy() {
  SizeBasedTriggeringPolicy triggeringPolicy = new SizeBasedTriggeringPolicy();
  triggeringPolicy.setContext(loggerContext);
  triggeringPolicy.setMaxFileSize(FileSize.valueOf(maxLogFileSize));
  triggeringPolicy.start();
  return triggeringPolicy;
}

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

public static void rollingPolicyForAppender(RollingFileAppender rollingFileAppender, String maxFileSize, String totalSizeCap, int maxHistory) {
  SizeAndTimeBasedRollingPolicy rollingPolicy = new SizeAndTimeBasedRollingPolicy();
  rollingPolicy.setContext(LOGGER_CONTEXT);
  rollingPolicy.setMaxHistory(maxHistory);
  rollingPolicy.setMaxFileSize(FileSize.valueOf(maxFileSize));
  rollingPolicy.setTotalSizeCap(FileSize.valueOf(totalSizeCap));
  rollingPolicy.setFileNamePattern(rollingFileAppender.rawFileProperty() + ".%d{yyyy-MM-dd}.%i.gz");
  rollingPolicy.setParent(rollingFileAppender);
  rollingFileAppender.setRollingPolicy(rollingPolicy);
  rollingPolicy.start();
}

代码示例来源: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: camunda/camunda-bpm-platform

public void setMaxFileSize(String maxFileSize) {
  this.maxFileSizeAsString = maxFileSize;
  this.maxFileSize = FileSize.valueOf(maxFileSize);
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void setMaxFileSize(String maxFileSize) {
 this.maxFileSizeAsString = maxFileSize;
 this.maxFileSize = FileSize.valueOf(maxFileSize);
}

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

@Override
protected RollingPolicy buildRollingPolicy(FileAppender<?> appender, String fileStr) {
  SizeAndTimeBasedRollingPolicy rollingPolicy = new SizeAndTimeBasedRollingPolicy();
  rollingPolicy.setParent(appender);
  rollingPolicy.setContext(loggerContext);
  if (getMaxLogFileSize() == null) {
    rollingPolicy.setFileNamePattern(fileStr + "%d{" + datePattern + "}");
  } else {
    rollingPolicy.setMaxFileSize(FileSize.valueOf(getMaxLogFileSize()));
    rollingPolicy.setFileNamePattern(fileStr + "%d{" + datePattern + "}.%i");
  }
  rollingPolicy.setMaxHistory(getMaxLogBackupFiles());
  rollingPolicy.start();
  return rollingPolicy;
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/ch.qos.logback.core

public void setMaxFileSize(String maxFileSize) {
  this.maxFileSizeAsString = maxFileSize;
  this.maxFileSize = FileSize.valueOf(maxFileSize);
 }
}

代码示例来源:origin: co.cask.cdap/cdap-watchdog

public void setMaxFileSize(String maxFileSize) {
  this.maxFileSizeAsString = maxFileSize;
  this.maxFileSize = FileSize.valueOf(maxFileSize);
 }
}

代码示例来源:origin: com.hynnet/logback-core

public void setMaxFileSize(String maxFileSize) {
  this.maxFileSizeAsString = maxFileSize;
  this.maxFileSize = FileSize.valueOf(maxFileSize);
 }
}

代码示例来源:origin: caskdata/cdap

public void setMaxFileSize(String maxFileSize) {
  this.maxFileSizeAsString = maxFileSize;
  this.maxFileSize = FileSize.valueOf(maxFileSize);
 }
}

代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand

public void setMaxFileSize(String maxFileSize) {
 this.maxFileSizeAsString = maxFileSize;
 this.maxFileSize = FileSize.valueOf(maxFileSize);
}

代码示例来源:origin: ch.qos.logback/core

public void setMaxFileSize(String maxFileSize) {
  this.maxFileSizeAsString = maxFileSize;
  this.maxFileSize = FileSize.valueOf(maxFileSize);
 }
}

代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand

public void setMaxFileSize(String maxFileSize) {
  this.maxFileSizeAsString = maxFileSize;
  this.maxFileSize = FileSize.valueOf(maxFileSize);
 }
}

代码示例来源:origin: com.hynnet/logback-core

public void setMaxFileSize(String maxFileSize) {
 this.maxFileSizeAsString = maxFileSize;
 this.maxFileSize = FileSize.valueOf(maxFileSize);
}

代码示例来源:origin: ch.qos.logback/core

public void setMaxFileSize(String maxFileSize) {
 this.maxFileSizeAsString = maxFileSize;
 this.maxFileSize = FileSize.valueOf(maxFileSize);
}

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

@Bean
public SizeBasedTriggeringPolicy<ILoggingEvent> sizeBasedTriggeringPolicy(LoggerContext loggerContext) {
  SizeBasedTriggeringPolicy<ILoggingEvent> sizeBasedTriggeringPolicy = new SizeBasedTriggeringPolicy<>();
  sizeBasedTriggeringPolicy.setContext(loggerContext);
  sizeBasedTriggeringPolicy.setMaxFileSize(FileSize.valueOf("10MB"));
  return sizeBasedTriggeringPolicy;
}

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

protected TriggeringPolicy buildTriggeringPolicy() {
  SizeBasedTriggeringPolicy triggeringPolicy = new SizeBasedTriggeringPolicy();
  triggeringPolicy.setContext(loggerContext);
  triggeringPolicy.setMaxFileSize(FileSize.valueOf(maxLogFileSize));
  triggeringPolicy.start();
  return triggeringPolicy;
}

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

protected void setupBasePolicySettings(TimeBasedRollingPolicy<ILoggingEvent> policy) {
    policy.setFileNamePattern(getFileNamePattern());
    if (getHistorySize() > 0) {
      policy.setMaxHistory(getHistorySize());
      policy.setCleanHistoryOnStart(true);
    }
    if (totalSize != null && totalSize.length() > 0) {
      policy.setTotalSizeCap(FileSize.valueOf(totalSize));
    }
  }
}

相关文章