本文整理了Java中ch.qos.logback.core.rolling.RollingFileAppender.setRollingPolicy
方法的一些代码示例,展示了RollingFileAppender.setRollingPolicy
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RollingFileAppender.setRollingPolicy
方法的具体详情如下:
包路径:ch.qos.logback.core.rolling.RollingFileAppender
类名称:RollingFileAppender
方法名:setRollingPolicy
[英]Sets the rolling policy. In case the 'policy' argument also implements TriggeringPolicy, then the triggering policy for this appender is automatically set to be the policy argument.
[中]设置滚动策略。如果“policy”参数也实现了TriggeringPolicy,那么这个appender的触发策略将自动设置为policy参数。
代码示例来源: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);
TimeBasedRollingPolicy rollingPolicy = new TimeBasedRollingPolicy();
rollingPolicy.setContext(context);
rollingPolicy.setFileNamePattern(StringUtils.replace(filePath, filenamePrefix + ".log", filenamePrefix + ".%d{" + datePattern + "}.log"));
rollingPolicy.setMaxHistory(maxFiles);
rollingPolicy.setParent(appender);
rollingPolicy.start();
appender.setRollingPolicy(rollingPolicy);
return appender;
}
}
代码示例来源:origin: apache/incubator-dubbo
policy.setParent(fileAppender);
policy.start();
fileAppender.setRollingPolicy(policy);
代码示例来源:origin: apache/incubator-dubbo
policy.setParent(fileAppender);
policy.start();
fileAppender.setRollingPolicy(policy);
代码示例来源:origin: org.springframework.boot/spring-boot
private void setRollingPolicy(RollingFileAppender<ILoggingEvent> appender,
LogbackConfigurator config, String logFile) {
SizeAndTimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new SizeAndTimeBasedRollingPolicy<>();
rollingPolicy.setFileNamePattern(logFile + ".%d{yyyy-MM-dd}.%i.gz");
setMaxFileSize(rollingPolicy,
this.patterns.getProperty("logging.file.max-size", MAX_FILE_SIZE));
rollingPolicy.setMaxHistory(this.patterns.getProperty("logging.file.max-history",
Integer.class, CoreConstants.UNBOUND_HISTORY));
appender.setRollingPolicy(rollingPolicy);
rollingPolicy.setParent(appender);
config.start(rollingPolicy);
}
代码示例来源: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: 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: kaaproject/kaa
rfAppender.setRollingPolicy(rollingPolicy);
rfAppender.setTriggeringPolicy(triggeringPolicy);
rfAppender.start();
代码示例来源:origin: alibaba/nacos
protected ch.qos.logback.core.Appender getLogbackDailyRollingFileAppender(String productName, String file,
String encoding) {
RollingFileAppender appender = new RollingFileAppender();
appender.setContext(LogbackLoggerContextUtil.getLoggerContext());
appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
appender.setAppend(true);
appender.setFile(LoggerHelper.getLogFile(productName, file));
TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
rolling.setParent(appender);
rolling.setFileNamePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}");
rolling.setContext(LogbackLoggerContextUtil.getLoggerContext());
rolling.start();
appender.setRollingPolicy(rolling);
PatternLayoutEncoder layout = new PatternLayoutEncoder();
layout.setPattern(LoggerHelper.getPattern(productName));
layout.setCharset(Charset.forName(encoding));
appender.setEncoder(layout);
layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();
// 启动
appender.start();
return appender;
}
代码示例来源: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: alibaba/nacos
protected ch.qos.logback.core.Appender getLogbackDailyRollingFileAppender(String productName, String file,
String encoding) {
RollingFileAppender appender = new RollingFileAppender();
appender.setContext(LogbackLoggerContextUtil.getLoggerContext());
appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
appender.setAppend(true);
appender.setFile(LoggerHelper.getLogFile(productName, file));
TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
rolling.setParent(appender);
rolling.setFileNamePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}");
rolling.setContext(LogbackLoggerContextUtil.getLoggerContext());
rolling.start();
appender.setRollingPolicy(rolling);
PatternLayout layout = new PatternLayout();
layout.setPattern(LoggerHelper.getPattern(productName));
layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();
appender.setLayout(layout);
// 启动
appender.start();
return appender;
}
代码示例来源:origin: stackoverflow.com
rfAppender.setRollingPolicy(rollingPolicy);
rfAppender.setTriggeringPolicy(triggeringPolicy);
代码示例来源:origin: alibaba/nacos
appender.setRollingPolicy(rolling);
代码示例来源:origin: dropwizard/dropwizard
rollingPolicy.setParent(appender);
rollingPolicy.start();
appender.setRollingPolicy(rollingPolicy);
rollingPolicy.setMaxHistory(archivedFileCount);
appender.setRollingPolicy(rollingPolicy);
代码示例来源:origin: alibaba/nacos
appender.setRollingPolicy(rolling);
appender.setTriggeringPolicy(triggerPolicy);
代码示例来源:origin: alibaba/nacos
appender.setRollingPolicy(rolling);
代码示例来源:origin: alibaba/nacos
appender.setRollingPolicy(rolling);
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: tony19/logback-android
@Override
protected Appender<Object> getConfiguredAppender() {
rfa.setContext(context);
tbrp
.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "toto-%d.log");
tbrp.start();
rfa.setRollingPolicy(tbrp);
rfa.start();
return rfa;
}
代码示例来源:origin: tony19/logback-android
@Before
public void setUp() {
rfa.setContext(context);
tbrp.setContext(context);
timeBasedFNATP.setContext(context);
rfa.setRollingPolicy(tbrp);
tbrp.setParent(rfa);
tbrp.setTimeBasedFileNamingAndTriggeringPolicy(timeBasedFNATP);
timeBasedFNATP.setTimeBasedRollingPolicy(tbrp);
}
代码示例来源:origin: tony19/logback-android
void initTRBP(RollingFileAppender<Object> rfa, TimeBasedRollingPolicy<Object> tbrp, String filenamePattern, long givenTime) {
tbrp.setContext(context);
tbrp.setFileNamePattern(filenamePattern);
tbrp.setParent(rfa);
tbrp.timeBasedFileNamingAndTriggeringPolicy = new DefaultTimeBasedFileNamingAndTriggeringPolicy<Object>();
tbrp.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(givenTime);
rfa.setRollingPolicy(tbrp);
tbrp.start();
rfa.start();
}
内容来源于网络,如有侵权,请联系作者删除!