Implement Logback Multi-day environment log configuration in Spring boot

Source: Internet
Author: User

In spring boot, you can define multiple environments in the springprofile tag in Logback.xml
Logback.xml:

<Springprofilename= "Production">    <Root Level= "DEBUG">        <Appender-refref= "STDOUT"/>    </Root></Springprofile><Springprofilename= "Dev">    <Root Level= "DEBUG">        <Appender-refref= "CONSOLE"/>    </Root></Springprofile>

Now you want to split the Logback.xml file into logback-production.xml,logback-dev.xml two files (logback-{profile}.xml) instead of being defined in the same file. The app then determines which configuration file to use based on profile.

Application.properties Inside Configuration:

Logging.config:classpath:logback-${spring.profiles.active}.xml

Specify at startup:

Java-jar Xxx.jar--spring.profiles.active=dev

You can also specify in Application.properties:

Spring.profiles.active=dev

Reference:

https://docs.spring.io/spring-boot/docs/1.5.7.RELEASE/reference/htmlsingle/# Boot-features-custom-log-configuration (Official configuration reference, all the answers are here)

http://blog.csdn.net/m0_37895333/article/details/72457007

Http://www.cnblogs.com/wuyechun/p/6800956.html

http://blog.csdn.net/vitech/article/details/53812137

Implement Logback Multi-day environment log configuration in Spring boot

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.