Springboot log integration log4j2

Springboot log integration log4j2

Steps for usage

Search spring-boot-starter-log4j2 in spring-boot-dependencies POMs and find that Spring boot parent Pom provides this dependency. We only need to add the corresponding dependency to use log4j2, not including the version number:
modify the pom.xml file

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <!--由于默认使用logback,在扩展log4j2之前先要把logback移除-->
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!--添加log4j2的相关依赖-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>

The next use is the same as the use of logback (address of logback)
https://blog.csdn.net/GanYangBa/article/details/109226473

Guess you like

Origin blog.csdn.net/GanYangBa/article/details/109228797