-
Notifications
You must be signed in to change notification settings - Fork 41k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Console logging incorrectly uses Charset.defaultCharset() #43118
Comments
The charset has been set to Having read the JEP, I think we should try to use One thing to note is that Flagging this for team attention to see what the rest of the team thinks. |
#23827 added the properties to set the charset. It looks like Logback uses the default charset if one is not specified. Log4J2 appears to default to UTF-8 if a charset is not specified. I guess both expect the user to actually configure things if the defaults don't work. I think I'd be in favor of using I think this could be a breaking change, and since there's a workaround I'm not sure we should do it until Boot 3.5. |
Prior to this commit, LogbackLoggingSystemProperties doesn't respect Console.charset(). It used Charset.getDefaultCharset() for logback and UTF-8 for log42j as defaults. This commit changes the behaviour of LogbackLoggingSystemProperties to use Console.charset() when available. If no console is present, the default charset is used instead. These changes bring consistency across logging implementations. See spring-projectsgh-43118 Signed-off-by: Dmytro Nosan <[email protected]>
Prior to this commit, LogbackLoggingSystemProperties doesn't respect Console.charset(). It used Charset.getDefaultCharset() for logback and UTF-8 for log42j as defaults. This commit changes the behaviour of LogbackLoggingSystemProperties to use Console.charset() when available. If no console is present, the default charset is used instead. These changes bring consistency across logging implementations. See spring-projectsgh-43118 Signed-off-by: Dmytro Nosan <[email protected]>
Superseded by #44353. |
Prior to this commit, LogbackLoggingSystemProperties doesn't respect Console.charset(). It used Charset.getDefaultCharset() for logback and UTF-8 for log42j as defaults. This commit changes the behaviour of LogbackLoggingSystemProperties to use Console.charset() when available. If no console is present, the default charset is used instead. These changes bring consistency across logging implementations. See gh-43118 Signed-off-by: Dmytro Nosan <[email protected]>
JEP 400: UTF-8 by Default was included in Java 18 and later version. Basically it changes the default
file.encoding
toUTF-8
by default and introduced a few additional properties to identify system native encoding. However the console output charset is different:However Spring Boot doesn't respect
Console.charset()
. It always useorg.springframework.boot.logging.LoggingSystemProperties.getDefaultCharset()
to set the default charset for console and file encoding. Depends on the implementation, it uses either hard-codedUTF-8
orCharset.defaultCharset()
.Below is a simple Spring Boot application to reproduce the issue (The system locale needs to be different than English):
Run it with Java 17:
Run it with Java 21 (my system locale is GBK):
The workaround is to add properties like below. But I think a better value should be provided by default.
logging.charset.console=${stdout.encoding}
The text was updated successfully, but these errors were encountered: