Github user garydgregory commented on a diff in the pull request:
https://github.com/apache/logging-log4j2/pull/88#discussion_r124051596
--- Diff:
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
---
@@ -83,6 +85,195 @@
private static final int DEFAULT_WINDOW_SIZE = 7;
/**
+ * Builds DefaultRolloverStrategy instances.
+ */
+ public static class Builder implements
org.apache.logging.log4j.core.util.Builder<DefaultRolloverStrategy> {
+ @PluginBuilderAttribute("max")
+ private String max;
+
+ @PluginBuilderAttribute("min")
+ private String min;
+
+ @PluginBuilderAttribute("fileIndex")
+ private String fileIndex;
+
+ @PluginBuilderAttribute("compressionLevel")
+ private String compressionLevelStr;
+
+ @PluginElement("Actions")
+ private Action[] customActions;
+
+ @PluginBuilderAttribute(value = "stopCustomActionsOnError")
+ private boolean stopCustomActionsOnError = true;
+
+ @PluginBuilderAttribute(value = "compressTmpFilePattern")
+ private String compressTmpFilePattern;
+
+ @PluginConfiguration
+ private Configuration config;
+
+ @Override
+ public DefaultRolloverStrategy build() {
+ int minIndex;
+ int maxIndex;
+ boolean useMax;
+
+ if (fileIndex != null && fileIndex.equalsIgnoreCase("nomax")) {
+ minIndex = Integer.MIN_VALUE;
+ maxIndex = Integer.MAX_VALUE;
+ useMax = false;
+ } else {
+ useMax = fileIndex == null ? true :
fileIndex.equalsIgnoreCase("max");
+ minIndex = MIN_WINDOW_SIZE;
+ if (min != null) {
+ minIndex = Integer.parseInt(min);
+ if (minIndex < 1) {
+ LOGGER.error("Minimum window size too small.
Limited to " + MIN_WINDOW_SIZE);
+ minIndex = MIN_WINDOW_SIZE;
+ }
+ }
+ maxIndex = DEFAULT_WINDOW_SIZE;
+ if (max != null) {
+ maxIndex = Integer.parseInt(max);
+ if (maxIndex < minIndex) {
+ maxIndex = minIndex < DEFAULT_WINDOW_SIZE ?
DEFAULT_WINDOW_SIZE : minIndex;
+ LOGGER.error("Maximum window size must be greater
than the minimum windows size. Set to " + maxIndex);
+ }
+ }
+ }
+ final int compressionLevel =
Integers.parseInt(compressionLevelStr, Deflater.DEFAULT_COMPRESSION);
+ return new DefaultRolloverStrategy(minIndex, maxIndex, useMax,
compressionLevel, config.getStrSubstitutor(),
+ customActions, stopCustomActionsOnError,
compressTmpFilePattern);
+ }
+
+ public String getMax() {
+ return max;
+ }
+
+ /**
+ * Define the maximum number of files to keep.
--- End diff --
Javadoc comments should use the active voice, IOW, "Defines..." instead of
"Define...". So you can read it as "The method foo defines...".
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---