Skip to content

Commit 3011155

Browse files
committed
Remove support for deprecated logback properties
This commit removes support for the following properties that are deprecated since Spring Boot 2.4: - logging.pattern.rolling-file-name - logging.file.clean-history-on-start - logging.file.max-size - logging.file.total-size-cap - logging.file.max-history Closes gh-48489
1 parent 66ba205 commit 3011155

File tree

5 files changed

+21
-55
lines changed

5 files changed

+21
-55
lines changed

core/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystemProperties.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ private void applyRollingPolicy(RollingPolicySystemProperty property, PropertyRe
106106
private <T> void applyRollingPolicy(RollingPolicySystemProperty property, PropertyResolver resolver,
107107
Class<T> type) {
108108
T value = getProperty(resolver, property.getApplicationPropertyName(), type);
109-
value = (value != null) ? value : getProperty(resolver, property.getDeprecatedApplicationPropertyName(), type);
110109
if (value != null) {
111110
String stringValue = String.valueOf((value instanceof DataSize dataSize) ? dataSize.toBytes() : value);
112111
setSystemProperty(property.getEnvironmentVariableName(), stringValue);

core/spring-boot/src/main/java/org/springframework/boot/logging/logback/RollingPolicySystemProperty.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,35 @@ public enum RollingPolicySystemProperty {
2929
/**
3030
* Logging system property for the rolled-over log file name pattern.
3131
*/
32-
FILE_NAME_PATTERN("file-name-pattern", "logging.pattern.rolling-file-name"),
32+
FILE_NAME_PATTERN("file-name-pattern"),
3333

3434
/**
3535
* Logging system property for the clean history on start flag.
3636
*/
37-
CLEAN_HISTORY_ON_START("clean-history-on-start", "logging.file.clean-history-on-start"),
37+
CLEAN_HISTORY_ON_START("clean-history-on-start"),
3838

3939
/**
4040
* Logging system property for the file log max size.
4141
*/
42-
MAX_FILE_SIZE("max-file-size", "logging.file.max-size"),
42+
MAX_FILE_SIZE("max-file-size"),
4343

4444
/**
4545
* Logging system property for the file total size cap.
4646
*/
47-
TOTAL_SIZE_CAP("total-size-cap", "logging.file.total-size-cap"),
47+
TOTAL_SIZE_CAP("total-size-cap"),
4848

4949
/**
5050
* Logging system property for the file log max history.
5151
*/
52-
MAX_HISTORY("max-history", "logging.file.max-history");
52+
MAX_HISTORY("max-history");
5353

5454
private final String environmentVariableName;
5555

5656
private final String applicationPropertyName;
5757

58-
private final String deprecatedApplicationPropertyName;
59-
60-
RollingPolicySystemProperty(String applicationPropertyName, String deprecatedApplicationPropertyName) {
58+
RollingPolicySystemProperty(String applicationPropertyName) {
6159
this.environmentVariableName = "LOGBACK_ROLLINGPOLICY_" + name();
6260
this.applicationPropertyName = "logging.logback.rollingpolicy." + applicationPropertyName;
63-
this.deprecatedApplicationPropertyName = deprecatedApplicationPropertyName;
6461
}
6562

6663
/**
@@ -75,8 +72,4 @@ String getApplicationPropertyName() {
7572
return this.applicationPropertyName;
7673
}
7774

78-
String getDeprecatedApplicationPropertyName() {
79-
return this.deprecatedApplicationPropertyName;
80-
}
81-
8275
}

core/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,26 @@
5555
{
5656
"name": "logging.file.clean-history-on-start",
5757
"type": "java.lang.Boolean",
58-
"description": "Whether to clean the archive log files on startup. Only supported with the default logback setup.",
59-
"sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener",
60-
"defaultValue": false,
6158
"deprecation": {
59+
"level": "error",
6260
"replacement": "logging.logback.rollingpolicy.clean-history-on-start",
6361
"since": "2.4.0"
6462
}
6563
},
6664
{
6765
"name": "logging.file.max-history",
6866
"type": "java.lang.Integer",
69-
"description": "Maximum number of archive log files to keep. Only supported with the default logback setup.",
70-
"sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener",
71-
"defaultValue": 7,
7267
"deprecation": {
68+
"level": "error",
7369
"replacement": "logging.logback.rollingpolicy.max-history",
7470
"since": "2.4.0"
7571
}
7672
},
7773
{
7874
"name": "logging.file.max-size",
7975
"type": "org.springframework.util.unit.DataSize",
80-
"description": "Maximum log file size. Only supported with the default logback setup.",
81-
"sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener",
82-
"defaultValue": "10MB",
8376
"deprecation": {
77+
"level": "error",
8478
"replacement": "logging.logback.rollingpolicy.max-file-size",
8579
"since": "2.4.0"
8680
}
@@ -100,10 +94,8 @@
10094
{
10195
"name": "logging.file.total-size-cap",
10296
"type": "org.springframework.util.unit.DataSize",
103-
"description": "Total size of log backups to be kept. Only supported with the default logback setup.",
104-
"sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener",
105-
"defaultValue": "0B",
10697
"deprecation": {
98+
"level": "error",
10799
"replacement": "logging.logback.rollingpolicy.total-size-cap",
108100
"since": "2.4.0"
109101
}
@@ -219,10 +211,8 @@
219211
{
220212
"name": "logging.pattern.rolling-file-name",
221213
"type": "java.lang.String",
222-
"description": "Pattern for rolled-over log file names. Supported only with the default Logback setup.",
223-
"sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener",
224-
"defaultValue": "${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz",
225214
"deprecation": {
215+
"level": "error",
226216
"replacement": "logging.logback.rollingpolicy.file-name-pattern",
227217
"since": "2.4.0"
228218
}

core/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemPropertiesTests.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,6 @@ void applySetsLogbackSystemProperties() {
8989
.containsEntry(RollingPolicySystemProperty.MAX_HISTORY.getEnvironmentVariableName(), "mh");
9090
}
9191

92-
@Test
93-
void applySetsLogbackSystemPropertiesFromDeprecated() {
94-
this.environment.setProperty("logging.pattern.rolling-file-name", "fnp");
95-
this.environment.setProperty("logging.file.clean-history-on-start", "chos");
96-
this.environment.setProperty("logging.file.max-size", "1KB");
97-
this.environment.setProperty("logging.file.total-size-cap", "2KB");
98-
this.environment.setProperty("logging.file.max-history", "mh");
99-
new LogbackLoggingSystemProperties(this.environment).apply();
100-
assertThat(System.getProperties())
101-
.containsEntry(RollingPolicySystemProperty.FILE_NAME_PATTERN.getEnvironmentVariableName(), "fnp")
102-
.containsEntry(RollingPolicySystemProperty.CLEAN_HISTORY_ON_START.getEnvironmentVariableName(), "chos")
103-
.containsEntry(RollingPolicySystemProperty.MAX_FILE_SIZE.getEnvironmentVariableName(), "1024")
104-
.containsEntry(RollingPolicySystemProperty.TOTAL_SIZE_CAP.getEnvironmentVariableName(), "2048")
105-
.containsEntry(RollingPolicySystemProperty.MAX_HISTORY.getEnvironmentVariableName(), "mh");
106-
}
107-
10892
@Test
10993
void consoleCharsetWhenNoPropertyUsesDefault() {
11094
LogbackLoggingSystemProperties logbackLoggingSystemProperties = spy(

core/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ void testFilePatternProperty(CapturedOutput output) {
398398

399399
@Test
400400
void testCleanHistoryOnStartProperty() {
401-
this.environment.setProperty("logging.file.clean-history-on-start", "true");
401+
this.environment.setProperty("logging.logback.rollingpolicy.clean-history-on-start", "true");
402402
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment);
403403
File file = new File(tmpDir(), "logback-test.log");
404404
LogFile logFile = getLogFile(file.getPath(), null);
@@ -411,7 +411,7 @@ void testCleanHistoryOnStartProperty() {
411411
@Test
412412
@WithIncludeBaseXmlResource
413413
void testCleanHistoryOnStartPropertyWithXmlConfiguration() {
414-
this.environment.setProperty("logging.file.clean-history-on-start", "true");
414+
this.environment.setProperty("logging.logback.rollingpolicy.clean-history-on-start", "true");
415415
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment);
416416
File file = new File(tmpDir(), "logback-test.log");
417417
LogFile logFile = getLogFile(file.getPath(), null);
@@ -437,7 +437,7 @@ void testMaxFileSizePropertyWithBytesValue() {
437437
}
438438

439439
private void testMaxFileSizeProperty(String sizeValue, String expectedFileSize) {
440-
this.environment.setProperty("logging.file.max-size", sizeValue);
440+
this.environment.setProperty("logging.logback.rollingpolicy.max-file-size", sizeValue);
441441
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment);
442442
File file = new File(tmpDir(), "logback-test.log");
443443
LogFile logFile = getLogFile(file.getPath(), null);
@@ -450,7 +450,7 @@ private void testMaxFileSizeProperty(String sizeValue, String expectedFileSize)
450450
@Test
451451
@WithIncludeBaseXmlResource
452452
void testMaxFileSizePropertyWithXmlConfiguration() {
453-
this.environment.setProperty("logging.file.max-size", "100MB");
453+
this.environment.setProperty("logging.logback.rollingpolicy.max-file-size", "100MB");
454454
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment);
455455
File file = new File(tmpDir(), "logback-test.log");
456456
LogFile logFile = getLogFile(file.getPath(), null);
@@ -462,7 +462,7 @@ void testMaxFileSizePropertyWithXmlConfiguration() {
462462

463463
@Test
464464
void testMaxHistoryProperty() {
465-
this.environment.setProperty("logging.file.max-history", "30");
465+
this.environment.setProperty("logging.logback.rollingpolicy.max-history", "30");
466466
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment);
467467
File file = new File(tmpDir(), "logback-test.log");
468468
LogFile logFile = getLogFile(file.getPath(), null);
@@ -475,7 +475,7 @@ void testMaxHistoryProperty() {
475475
@Test
476476
@WithIncludeBaseXmlResource
477477
void testMaxHistoryPropertyWithXmlConfiguration() {
478-
this.environment.setProperty("logging.file.max-history", "30");
478+
this.environment.setProperty("logging.logback.rollingpolicy.max-history", "30");
479479
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment);
480480
File file = new File(tmpDir(), "logback-test.log");
481481
LogFile logFile = getLogFile(file.getPath(), null);
@@ -501,7 +501,7 @@ void testTotalSizeCapPropertyWithBytesValue() {
501501
}
502502

503503
private void testTotalSizeCapProperty(String sizeValue, String expectedFileSize) {
504-
this.environment.setProperty("logging.file.total-size-cap", sizeValue);
504+
this.environment.setProperty("logging.logback.rollingpolicy.total-size-cap", sizeValue);
505505
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment);
506506
File file = new File(tmpDir(), "logback-test.log");
507507
LogFile logFile = getLogFile(file.getPath(), null);
@@ -515,7 +515,7 @@ private void testTotalSizeCapProperty(String sizeValue, String expectedFileSize)
515515
@WithIncludeBaseXmlResource
516516
void testTotalSizeCapPropertyWithXmlConfiguration() {
517517
String expectedSize = "101 MB";
518-
this.environment.setProperty("logging.file.total-size-cap", expectedSize);
518+
this.environment.setProperty("logging.logback.rollingpolicy.total-size-cap", expectedSize);
519519
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment);
520520
File file = new File(tmpDir(), "logback-test.log");
521521
LogFile logFile = getLogFile(file.getPath(), null);
@@ -773,9 +773,9 @@ void logbackSystemStatusListenerShouldBeRegisteredWhenUsingCustomLogbackXml(Capt
773773
}
774774

775775
@Test
776-
void testRollingFileNameProperty() {
776+
void testRollingFileNamePatternProperty() {
777777
String rollingFile = "my.log.%d{yyyyMMdd}.%i.gz";
778-
this.environment.setProperty("logging.pattern.rolling-file-name", rollingFile);
778+
this.environment.setProperty("logging.logback.rollingpolicy.file-name-pattern", rollingFile);
779779
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment);
780780
File file = new File(tmpDir(), "my.log");
781781
LogFile logFile = getLogFile(file.getPath(), null);

0 commit comments

Comments
 (0)