springboot日志集成log4j2

springboot日志集成log4j2

使用步骤

在spring-boot-dependencies POMs中搜索spring-boot-starter-log4j2发现Spring boot parent Pom中自己提供了这个依赖,我们使用log4j2只需要加入相应的依赖,不包含版本号:
修改pom.xml文件

<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>

接下来的使用与logback的使用是一样的(logback的地址)
https://blog.csdn.net/GanYangBa/article/details/109226473

猜你喜欢

转载自blog.csdn.net/GanYangBa/article/details/109228797
今日推荐