本文整理了Java中ch.qos.logback.core.rolling.FixedWindowRollingPolicy
类的一些代码示例,展示了FixedWindowRollingPolicy
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FixedWindowRollingPolicy
类的具体详情如下:
包路径:ch.qos.logback.core.rolling.FixedWindowRollingPolicy
类名称:FixedWindowRollingPolicy
[英]When rolling over, FixedWindowRollingPolicy
renames files according to a fixed window algorithm. For more information about this policy, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#FixedWindowRollingPolicy
[中]滚动时,FixedWindowRollingPolicy
根据固定窗口算法重命名文件。有关此政策的更多信息,请参阅在线手册,网址为http://logback.qos.ch/manual/appenders.html#FixedWindowRollingPolicy
代码示例来源:origin: jmxtrans/jmxtrans
protected RollingPolicy buildRollingPolicy(FileAppender<?> appender, String fileStr) {
FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
rollingPolicy.setParent(appender);
rollingPolicy.setContext(loggerContext);
rollingPolicy.setMinIndex(1);
rollingPolicy.setMaxIndex(maxLogBackupFiles);
rollingPolicy.setFileNamePattern(fileStr + ".%i");
rollingPolicy.start();
return rollingPolicy;
}
代码示例来源:origin: camunda/camunda-bpm-platform
determineCompressionMode();
} else {
addError(FNP_NOT_SET);
addError(CoreConstants.SEE_FNP_NOT_SET);
throw new IllegalStateException(FNP_NOT_SET + CoreConstants.SEE_FNP_NOT_SET);
if(isParentPrudent()) {
addError("Prudent mode is not supported with FixedWindowRollingPolicy.");
addError(PRUDENT_MODE_UNSUPPORTED);
throw new IllegalStateException("Prudent mode is not supported.");
if (getParentsRawFileProperty() == null) {
addError("The File name property must be set before using this rolling policy.");
addError(SEE_PARENT_FN_NOT_SET);
throw new IllegalStateException("The \"File\" option must be set.");
addWarn("MaxIndex (" + maxIndex + ") cannot be smaller than MinIndex ("
+ minIndex + ").");
addWarn("Setting maxIndex to equal minIndex.");
maxIndex = minIndex;
final int maxWindowSize = getMaxWindowSize();
if ((maxIndex - minIndex) > maxWindowSize) {
addWarn("Large window sizes are not allowed.");
maxIndex = minIndex + maxWindowSize;
addWarn("MaxIndex reduced to " + maxIndex);
String zipEntryFileNamePatternStr = transformFileNamePatternFromInt2Date(fileNamePatternStr);
zipEntryFileNamePattern = new FileNamePattern(zipEntryFileNamePatternStr, context);
代码示例来源:origin: com.github.tornaia/aott-desktop-client-core
@Bean
public FixedWindowRollingPolicy fixedWindowRollingPolicy(SessionSettingsProvider sessionSettingsProvider, LoggerContext loggerContext) {
FixedWindowRollingPolicy fixedWindowRollingPolicy = new FixedWindowRollingPolicy();
fixedWindowRollingPolicy.setContext(loggerContext);
fixedWindowRollingPolicy.setMinIndex(1);
fixedWindowRollingPolicy.setMaxIndex(100);
fixedWindowRollingPolicy.setFileNamePattern(sessionSettingsProvider.getLogsDirectory().resolve("desktop-client.%i.log.zip").toString());
return fixedWindowRollingPolicy;
}
代码示例来源:origin: camunda/camunda-bpm-platform
util.rename(toRenameStr, fileNamePattern.convertInt(i + 1));
} else {
addInfo("Skipping roll-over for inexistent file " + toRenameStr);
util.rename(getActiveFileName(), fileNamePattern
.convertInt(minIndex));
break;
case GZ:
compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), null);
break;
case ZIP:
compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), zipEntryFileNamePattern.convert(new Date()));
break;
代码示例来源: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
/**
* Test whether FixedWindowRollingPolicy throws an exception when the
* ActiveFileName is not set.
*/
@Test(expected = IllegalStateException.class)
public void activeFileNameNotSet() {
sizeBasedTriggeringPolicy.setMaxFileSize(new FileSize(100));
sizeBasedTriggeringPolicy.start();
fwrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "sizeBased-test1.%i");
fwrp.start();
// The absence of activeFileName option should cause an exception.
}
代码示例来源:origin: tony19/logback-android
@Before
@Override
public void setUp() throws ParseException {
super.setUp();
fwrp.setContext(context);
fwrp.setParent(rfa);
rfa.setContext(context);
sizeBasedTriggeringPolicy.setContext(context);
}
代码示例来源:origin: org.restcomm.imscf/imscf-common
@Override
public void start() {
super.start();
String path = getActiveFileName();
if (path != null && !FILES_ROTATED_AT_STARTUP.contains(path)) {
FILES_ROTATED_AT_STARTUP.add(path);
try {
rollover();
System.out.println("Executed initial rollover for file " + path);
} catch (RolloverFailure e) {
System.out.println("Failed to execute initial rollover for file " + path);
}
}
}
代码示例来源: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: com.alibaba.citrus.tool/antx-autoexpand
determineCompressionMode();
} else {
addError(FNP_NOT_SET);
addError(CoreConstants.SEE_FNP_NOT_SET);
throw new IllegalStateException(FNP_NOT_SET + CoreConstants.SEE_FNP_NOT_SET);
if(isParentPrudent()) {
addError("Prudent mode is not supported with FixedWindowRollingPolicy.");
addError(PRUDENT_MODE_UNSUPPORTED);
throw new IllegalStateException("Prudent mode is not supported.");
if (getParentsRawFileProperty() == null) {
addError("The File name property must be set before using this rolling policy.");
addError(SEE_PARENT_FN_NOT_SET);
throw new IllegalStateException("The \"File\" option must be set.");
addWarn("MaxIndex (" + maxIndex + ") cannot be smaller than MinIndex ("
+ minIndex + ").");
addWarn("Setting maxIndex to equal minIndex.");
maxIndex = minIndex;
addWarn("Large window sizes are not allowed.");
maxIndex = minIndex + MAX_WINDOW_SIZE;
addWarn("MaxIndex reduced to " + maxIndex);
代码示例来源:origin: com.nhl.bootique.logback/bootique-logback
@Override
protected FixedWindowRollingPolicy instantiatePolicy(LoggerContext context) {
FixedWindowRollingPolicy policy = new FixedWindowRollingPolicy();
policy.setFileNamePattern(getFileNamePattern());
if (getHistorySize() > 0) {
policy.setMinIndex(1);
policy.setMaxIndex(getHistorySize());
}
policy.setContext(context);
return policy;
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
util.rename(toRenameStr, fileNamePattern.convertInt(i + 1));
} else {
addInfo("Skipping roll-over for inexistent file " + toRenameStr);
util.rename(getActiveFileName(), fileNamePattern.convertInt(minIndex));
break;
case GZ:
compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), null);
break;
case ZIP:
compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), zipEntryFileNamePattern.convert(new Date()));
break;
代码示例来源:origin: com.github.tornaia/aott-desktop-client-core
@Override
public void afterPropertiesSet() {
patternLayoutEncoder.start();
fixedWindowRollingPolicy.start();
sizeBasedTriggeringPolicy.start();
rollingFileAppender.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: Nextdoor/bender
determineCompressionMode();
} else {
addError(FNP_NOT_SET);
addError(CoreConstants.SEE_FNP_NOT_SET);
throw new IllegalStateException(FNP_NOT_SET + CoreConstants.SEE_FNP_NOT_SET);
if (isParentPrudent()) {
addError("Prudent mode is not supported with FixedWindowRollingPolicy.");
addError(PRUDENT_MODE_UNSUPPORTED);
throw new IllegalStateException("Prudent mode is not supported.");
if (getParentsRawFileProperty() == null) {
addError("The File name property must be set before using this rolling policy.");
addError(SEE_PARENT_FN_NOT_SET);
throw new IllegalStateException("The \"File\" option must be set.");
addWarn("MaxIndex (" + maxIndex + ") cannot be smaller than MinIndex (" + minIndex + ").");
addWarn("Setting maxIndex to equal minIndex.");
maxIndex = minIndex;
final int maxWindowSize = getMaxWindowSize();
if ((maxIndex - minIndex) > maxWindowSize) {
addWarn("Large window sizes are not allowed.");
maxIndex = minIndex + maxWindowSize;
addWarn("MaxIndex reduced to " + maxIndex);
String zipEntryFileNamePatternStr = transformFileNamePatternFromInt2Date(fileNamePatternStr);
zipEntryFileNamePattern = new FileNamePattern(zipEntryFileNamePatternStr, context);
代码示例来源:origin: com.hynnet/logback-core
util.rename(toRenameStr, fileNamePattern.convertInt(i + 1));
} else {
addInfo("Skipping roll-over for inexistent file " + toRenameStr);
util.rename(getActiveFileName(), fileNamePattern
.convertInt(minIndex));
break;
case GZ:
compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), null);
break;
case ZIP:
compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), zipEntryFileNamePattern.convert(new Date()));
break;
代码示例来源:origin: alibaba/nacos
triggerPolicy.start();
FixedWindowRollingPolicy rolling = new FixedWindowRollingPolicy();
rolling.setContext(LogbackLoggerContextUtil.getLoggerContext());
rolling.setParent(appender);
rolling.setFileNamePattern(LoggerHelper.getLogFile(productName, file) + ".%i");
rolling.setParent(appender);
if (maxBackupIndex >= 0) {
rolling.setMaxIndex(maxBackupIndex);
rolling.start();
代码示例来源:origin: ch.qos.logback/core
determineCompressionMode();
} else {
addError(FNP_NOT_SET);
addError(CoreConstants.SEE_FNP_NOT_SET);
throw new IllegalStateException(FNP_NOT_SET + CoreConstants.SEE_FNP_NOT_SET);
if(isParentPrudent()) {
addError("Prudent mode is not supported with FixedWindowRollingPolicy.");
addError(PRUDENT_MODE_UNSUPPORTED);
throw new IllegalStateException("Prudent mode is not supported.");
if (getParentsRawFileProperty() == null) {
addError("The File name property must be set before using this rolling policy.");
addError(SEE_PARENT_FN_NOT_SET);
throw new IllegalStateException("The \"File\" option must be set.");
addWarn("MaxIndex (" + maxIndex + ") cannot be smaller than MinIndex ("
+ minIndex + ").");
addWarn("Setting maxIndex to equal minIndex.");
maxIndex = minIndex;
addWarn("Large window sizes are not allowed.");
maxIndex = minIndex + MAX_WINDOW_SIZE;
addWarn("MaxIndex reduced to " + maxIndex);
String zipEntryFileNamePatternStr = transformFileNamePatternFromInt2Date(fileNamePatternStr);
zipEntryFileNamePattern = new FileNamePattern(zipEntryFileNamePatternStr, context);
代码示例来源:origin: tony19/logback-android
util.rename(toRenameStr, fileNamePattern.convertInt(i + 1));
} else {
addInfo("Skipping roll-over for inexistent file " + toRenameStr);
util.rename(getActiveFileName(), fileNamePattern
.convertInt(minIndex));
break;
case GZ:
compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), null);
break;
case ZIP:
compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), zipEntryFileNamePattern.convert(new Date()));
break;
代码示例来源:origin: alibaba/nacos
triggerPolicy.start();
FixedWindowRollingPolicy rolling = new FixedWindowRollingPolicy();
rolling.setContext(LogbackLoggerContextUtil.getLoggerContext());
rolling.setParent(appender);
rolling.setFileNamePattern(LoggerHelper.getLogFile(productName, file) + ".%i");
rolling.setParent(appender);
if (maxBackupIndex >= 0) {
rolling.setMaxIndex(maxBackupIndex);
rolling.start();
内容来源于网络,如有侵权,请联系作者删除!