Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.boot.logging.logback;

import java.io.Console;
import java.io.File;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down Expand Up @@ -597,7 +598,7 @@ void initializeShouldApplyLogbackSystemPropertiesToTheContext() {
expectedProperties.add("CONSOLE_LOG_STRUCTURED_FORMAT");
expectedProperties.add("FILE_LOG_STRUCTURED_FORMAT");
assertThat(properties).containsOnlyKeys(expectedProperties);
assertThat(properties).containsEntry("CONSOLE_LOG_CHARSET", Charset.defaultCharset().name());
assertThat(properties).containsEntry("CONSOLE_LOG_CHARSET", getConsoleCharset());
}

@Test
Expand Down Expand Up @@ -1156,6 +1157,11 @@ private void initialize(LoggingInitializationContext context, String configLocat
this.loggingSystem.initialize(context, configLocation, logFile);
}

private static String getConsoleCharset() {
Console console = System.console();
return (console != null) ? console.charset().name() : Charset.defaultCharset().name();
}

private static Logger getRootLogger() {
ILoggerFactory factory = LoggerFactory.getILoggerFactory();
LoggerContext context = (LoggerContext) factory;
Expand Down