Skip to content
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

Since 2.4.2, the Logback charset defaults to UTF-8 rather than the OS's default #24894

Closed
jonesun opened this issue Jan 20, 2021 · 8 comments
Closed
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@jonesun
Copy link

jonesun commented Jan 20, 2021

When I use version 2.4.2, package it into a jar, and run it with cmd: java -jar demo-0.0.1-SNAPSHOT.jar, the log output is garbled. But after falling back to 2.4.1, using the same method again, it is completely normal. The attachment is the result comparison:

use-2 4 1
use-2 4 2

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 20, 2021
@philwebb
Copy link
Member

I wonder if the change we made for #24835 has had some kind of unexpected side-effect.

@jonesun I assume the last three lines are the issue? Perhaps logging.charset.console is has changed somehow. What's your default charset? Are you able to provide a sample application that shows the problem?

@philwebb philwebb added the status: waiting-for-feedback We need additional information before we can continue label Jan 20, 2021
@jonesun
Copy link
Author

jonesun commented Jan 20, 2021

this is my demo project demo

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 20, 2021
@jonesun
Copy link
Author

jonesun commented Jan 20, 2021

thank you for your reply. my windows default charset is gbk, and my idea use utf-8

@jonesun
Copy link
Author

jonesun commented Jan 20, 2021

@philwebb I just followed your prompt and changed the application.yml, it's ok:

logging:
  charset:
    console: gbk

thank you very much!

@jonesun jonesun closed this as completed Jan 21, 2021
@philwebb philwebb reopened this Jan 21, 2021
@philwebb
Copy link
Member

Reopening because I'd like to dig into why the property wasn't needed before.

@jonesun
Copy link
Author

jonesun commented Jan 21, 2021

@philwebb ok

@wilkinsona
Copy link
Member

wilkinsona commented Jan 25, 2021

Thanks for the sample, @jonesun. It's allowed to confirm that the fix for #24835 is the problem.

DefaultLogbackConfiguration and LoggingSystemProperties have different defaults for CONSOLE_LOG_CHARSET. The former using default (the JVM's default) and the latter used UTF-8. In 2.4.1, LoggingSystemProperties does affect the logger context. As a result, CONSOLE_LOG_CHARSET is unset and its default (the JVM's default charset) is used by the console appender. In 2.4.2, LoggingSystemProperties does affect the logger context and, as a result, CONSOLE_LOG_CHARSET is set with LoggingSystemProperties' default which is UTF-8. This is then used by the console appender.

The fix for #24835 was intended to reinstate the lines removed in fb25104. The lines didn't set CONSOLE_LOG_CHARSET so perhaps we've swung back too far in the opposite direction and we should be more selective about the properties that are applied to the logger context. On the other hand, applying only a subset of properties seems inconsistent.

@wilkinsona wilkinsona added for: team-attention An issue we'd like other members of the team to review and removed status: feedback-provided Feedback has been provided labels Jan 25, 2021
@wilkinsona wilkinsona changed the title use 2.4.2 print log garbled Since 2.4.2, the console appender's charset defaults to UTF-8 rather than the OS's default Jan 25, 2021
@philwebb philwebb added type: bug A general bug type: regression A regression from a previous release and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Jan 25, 2021
@philwebb philwebb added this to the 2.4.x milestone Jan 25, 2021
@philwebb
Copy link
Member

This line should use the LogbackLoggingSystemProperties subclass.

@philwebb philwebb changed the title Since 2.4.2, the console appender's charset defaults to UTF-8 rather than the OS's default Since 2.4.2, the Logback charset defaults to UTF-8 rather than the OS's default Jan 25, 2021
@wilkinsona wilkinsona self-assigned this Feb 12, 2021
@wilkinsona wilkinsona modified the milestones: 2.4.x, 2.4.3 Feb 12, 2021
This was referenced Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants