From c6b55c99adeb5ac9a4f43761c8dd35464c32adc7 Mon Sep 17 00:00:00 2001 From: David Roussel Date: Wed, 17 Apr 2013 18:56:16 +0100 Subject: [PATCH 1/2] LOGBACK-266 - allow max window size to be overriden --- .../core/rolling/FixedWindowRollingPolicy.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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..e1f79efe65 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 @@ -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); From 7c926d856c883f192bbb9bddfa0aebd647c962d9 Mon Sep 17 00:00:00 2001 From: David Roussel Date: Fri, 19 Apr 2013 11:10:18 +0100 Subject: [PATCH 2/2] LOGBACK-266 - increase max window size of FixedWindowRollingPolicy to 20. 12 is too restrictive, and the users have voted for it to be increased --- .../ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 e1f79efe65..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;