Update LogbackLoggingSystemTests to use Console.charset() when available
See gh-44477 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
This commit is contained in:
parent
f01199341b
commit
b140fd1c4c
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.boot.logging.logback;
|
package org.springframework.boot.logging.logback;
|
||||||
|
|
||||||
|
import java.io.Console;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@ -597,7 +598,7 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
|
|||||||
expectedProperties.add("CONSOLE_LOG_STRUCTURED_FORMAT");
|
expectedProperties.add("CONSOLE_LOG_STRUCTURED_FORMAT");
|
||||||
expectedProperties.add("FILE_LOG_STRUCTURED_FORMAT");
|
expectedProperties.add("FILE_LOG_STRUCTURED_FORMAT");
|
||||||
assertThat(properties).containsOnlyKeys(expectedProperties);
|
assertThat(properties).containsOnlyKeys(expectedProperties);
|
||||||
assertThat(properties).containsEntry("CONSOLE_LOG_CHARSET", Charset.defaultCharset().name());
|
assertThat(properties).containsEntry("CONSOLE_LOG_CHARSET", getConsoleCharset());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -1156,6 +1157,11 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
|
|||||||
this.loggingSystem.initialize(context, configLocation, logFile);
|
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() {
|
private static Logger getRootLogger() {
|
||||||
ILoggerFactory factory = LoggerFactory.getILoggerFactory();
|
ILoggerFactory factory = LoggerFactory.getILoggerFactory();
|
||||||
LoggerContext context = (LoggerContext) factory;
|
LoggerContext context = (LoggerContext) factory;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user