diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java index 914d7450eb..7573a888f6 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java @@ -40,9 +40,9 @@ public class FixedWindowRollingPolicy extends RollingPolicyBase { public static final String ZIP_ENTRY_DATE_PATTERN = "yyyy-MM-dd_HHmm"; /** - * It's almost always a bad idea to have a large window size, say over 12. + * It's almost always a bad idea to have a large window size, say over 20. */ - private static int MAX_WINDOW_SIZE = 12; + private static int MAX_WINDOW_SIZE = 20; public FixedWindowRollingPolicy() { minIndex = 1; @@ -80,9 +80,10 @@ public void start() { maxIndex = minIndex; } - if ((maxIndex - minIndex) > MAX_WINDOW_SIZE) { + final int maxWindowSize = getMaxWindowSize(); + if ((maxIndex - minIndex) > maxWindowSize) { addWarn("Large window sizes are not allowed."); - maxIndex = minIndex + MAX_WINDOW_SIZE; + maxIndex = minIndex + maxWindowSize; addWarn("MaxIndex reduced to " + maxIndex); } @@ -103,6 +104,15 @@ public void start() { super.start(); } + /** + * Subclasses can override this method to increase the max window size, if required. This is to + * address LOGBACK-266. + * @return + */ + protected int getMaxWindowSize() { + return MAX_WINDOW_SIZE; + } + private String transformFileNamePatternFromInt2Date(String fileNamePatternStr) { String slashified = FileFilterUtil.slashify(fileNamePatternStr); String stemOfFileNamePattern = FileFilterUtil.afterLastSlash(slashified);