Windows launches Tomcat, log garbled issues, log schema Springboot+logback

Source: Internet
Author: User

Recently in the framework of the migration work, the original SPRINGMVC project to adjust to the Springboot architecture, after the migration, found to use the Springboot as a jar package boot normal, with Tomcat to start the log garbled, but the project deployment to the Linux environment boot is also normal, The following is the log garbled code:

<?xml version= "1.0" encoding= "UTF-8"?>
<configuration>
<include resource= "Org/springframework/boot/logging/logback/base.xml"/>
<logger name= "Org.springframework.web" level= "INFO"/>
<logger name= "Org.springboot.sample" level= "TRACE"/>

<!-- 开发、测试环境 --><springProfile name="dev,test,devtest">    <logger name="org.springframework.web" level="INFO"/>    <logger name="org.springboot.sample" level="INFO" />    <logger name="hwja.com" level="DEBUG" /></springProfile><!-- 生产环境 --><springProfile name="prod">    <logger name="org.springframework.web" level="ERROR"/>    <logger name="org.springboot.sample" level="ERROR" />    <logger name="hwja.com" level="ERROR" /></springProfile>

</configuration>
Let's take a look at the following:

Windows system default encoding GBK, and the project encoding unified UTF-8, and Springboot integrated logback log default encoding is also set UTF-8, so the log output is garbled, Linux under all UTF-8, so normal, then how to solve it, The solution will springboot integrated logback log default encoding, let it automatically read the operating system's environment code, also is the default Tomcat in the default value of File.encoding, the following log code to resolve:

<?xml version= "1.0" encoding= "UTF-8"?>
<configuration>
<include resource= "Org/springframework/boot/logging/logback/defaults.xml"/>
<property name= "Log_file" value= "${log_file:-${log_path:-${log_temp:-${java.io.tmpdir:-/tmp}}}/spring.log}"/ >
<appender name= "CONSOLE" class= "Ch.qos.logback.core.ConsoleAppender" >
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<!--note here to remove the encoding so that it reads the operating system by default--

If you still have a problem, you can contact me qq:604313052 wx:ca604313052

Windows launches Tomcat, log garbled issues, log schema Springboot+logback

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.