Log components for Springboot

Source: Internet
Author: User

First, brief

Springboot itself provides default profiles for SLF4J, log4j (including log4j2), Logback, and in the default settings, Springboot is to print log information only in the console, not output to the log file.

In dependent Spring-boot-starter-web, the dependency of Logback is included, that is, if <artifactid>spring-boot-starter-web</artifactid is referenced , the use of the self-logback;

If you do not want to use the logback of the Springboot band, you can exclude logback when referencing dependencies;

<dependencies>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-web</artifactId>            <exclusions><!--Remove logging from the default configuration                <exclusion>                    <groupId>org.springframework.boot</groupId>                    <artifactId> spring-boot-starter-logging</artifactid>                </exclusion>            </exclusions>        </ Dependency>        <dependency> <!--introducing LOG4J2 dependencies or other log components--            <groupId> Org.springframework.boot</groupid>            <artifactId>spring-boot-starter-log4j2</artifactId>        </dependency>    </dependencies>    

 

Ii. using a custom log component

Springboot supports the use of custom log components and profiles: Excludes dependencies on the default logging framework, and introduces dependencies on the log components used;

The configuration file is named Log4j2-spring.xml or Log4j2.xml (others, such as Logback-spring.xml or Logback.xml), and is recommended in xxx-spring.xml form. This eliminates the need for APPLICATION.YML configuration;

Log components for Springboot

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.