Skip to content

Commit c559b15

Browse files
committed
Switching Logback's file logging charset to UTF-8
Aligns the file charset between Log4j2 and Logback. Prior to this commit, there was an inconsistency between the two: Log4j2 used UTF-8, while Logback used Charset.defaultCharset(), which is platform-dependent. Signed-off-by: Dmytro Nosan <[email protected]>
1 parent 42d0f72 commit c559b15

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.boot.logging.logback;
1818

1919
import java.io.Console;
20-
import java.nio.charset.Charset;
2120
import java.util.function.BiConsumer;
2221
import java.util.function.Function;
2322

@@ -78,11 +77,6 @@ public LogbackLoggingSystemProperties(Environment environment,
7877
return super.getConsole();
7978
}
8079

81-
@Override
82-
protected Charset getDefaultFileCharset() {
83-
return Charset.defaultCharset();
84-
}
85-
8680
@Override
8781
protected void apply(@Nullable LogFile logFile, PropertyResolver resolver) {
8882
super.apply(logFile, resolver);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ void consoleCharsetWhenNoPropertyUsesSystemConsoleCharsetWhenAvailable() {
131131
}
132132

133133
@Test
134-
void fileCharsetWhenNoPropertyUsesDefault() {
134+
void fileCharsetWhenNoPropertyUsesUtf8() {
135135
new LoggingSystemProperties(new MockEnvironment()).apply(null);
136136
assertThat(System.getProperty(LoggingSystemProperty.FILE_CHARSET.getEnvironmentVariableName()))
137-
.isEqualTo(Charset.defaultCharset().name());
137+
.isEqualTo(StandardCharsets.UTF_8.name());
138138
}
139139

140140
}

0 commit comments

Comments
 (0)