How to resolve the issue of jumbled characters in Spring Boot logs?

To solve the problem of garbled Spring Boot logs, you can take the following steps:

  1. Configure the log output encoding in the application.properties or application.yml file, for example:
  2. The encoding of the log file is set to UTF-8.
  3. Set the system default encoding to UTF-8 in the main method, for example:
  4. In the code above, the main method is defined as public and static, and it sets the system property “file.encoding” to UTF-8. It then runs the Spring application with the class Application and the provided command line arguments.
  5. Make sure that the encoding of the log files is consistent with the configuration, for example by using UTF-8 encoding.
  6. To configure the Appender for logging to the console, for instance when using ConsoleAppender to output to the console, add the following configuration:
  7. The encoding for the console in log4j is set to UTF-8.
  8. When using the logback.xml configuration file, add the following configuration:


  9. UTF-8



  10. If you are using Logback as the logging framework, you can also configure the logging encoding in the logback.xml configuration file, for example:


  11. ${console.encoding}





  12. If the above methods still cannot solve the garbled code problem, you can try using other logging frameworks or encoding filters to address the issue.
bannerAds