diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java
index d55bb45a06..0838a7357a 100644
--- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java
+++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java
@@ -61,6 +61,8 @@ class DefaultLogbackConfiguration {
private static final DataSize MAX_FILE_SIZE = DataSize.ofMegabytes(10);
+ private static final Integer MAX_FILE_HISTORY = 7;
+
private final PropertyResolver patterns;
private final LogFile logFile;
@@ -148,7 +150,7 @@ class DefaultLogbackConfiguration {
setMaxFileSize(rollingPolicy,
getDataSize("logging.file.max-size", MAX_FILE_SIZE));
rollingPolicy.setMaxHistory(this.patterns.getProperty("logging.file.max-history",
- Integer.class, CoreConstants.UNBOUND_HISTORY));
+ Integer.class, MAX_FILE_HISTORY));
DataSize totalSizeCap = getDataSize("logging.file.total-size-cap",
DataSize.ofBytes(CoreConstants.UNBOUNDED_TOTAL_SIZE_CAP));
rollingPolicy.setTotalSizeCap(new FileSize(totalSizeCap.toBytes()));
diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index 6169bd4c20..85da258647 100644
--- a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -107,7 +107,7 @@
"type": "java.lang.Integer",
"description": "Maximum of archive log files to keep. Only supported with the default logback setup.",
"sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener",
- "defaultValue": 0
+ "defaultValue": 7
},
{
"name": "logging.file.total-size-cap",
diff --git a/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/file-appender.xml b/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/file-appender.xml
index f081a5ade5..05bae318e3 100644
--- a/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/file-appender.xml
+++ b/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/file-appender.xml
@@ -16,7 +16,7 @@ initialization performed by Boot
${LOG_FILE_CLEAN_HISTORY_ON_START:-false}
${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz
${LOG_FILE_MAX_SIZE:-10MB}
- ${LOG_FILE_MAX_HISTORY:-0}
+ ${LOG_FILE_MAX_HISTORY:-7}
${LOG_FILE_TOTAL_SIZE_CAP:-0}
diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java
index d5de6d834c..d09aae9312 100644
--- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java
+++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java
@@ -27,7 +27,6 @@ import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.LoggerContextListener;
import ch.qos.logback.core.ConsoleAppender;
-import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.rolling.RollingFileAppender;
import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy;
import org.hamcrest.Matcher;
@@ -134,8 +133,7 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
assertThat(getLineWithText(file, "Hello world")).contains("INFO");
assertThat(ReflectionTestUtils.getField(getRollingPolicy(), "maxFileSize")
.toString()).isEqualTo("10 MB");
- assertThat(getRollingPolicy().getMaxHistory())
- .isEqualTo(CoreConstants.UNBOUND_HISTORY);
+ assertThat(getRollingPolicy().getMaxHistory()).isEqualTo(7);
}
@Test