spring-boot中使用log4j

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36209121/article/details/78815038

log4j的配置

spring-boot默认使用的是logback, 由于习惯使用log4j, 下面是使用log4j的配置.

1 忽略spring-boot的 日志的默认配置;

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>

    <exclusions>
      <exclusion>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-logging</artifactId>
      </exclusion>
   </exclusions>
</dependency>

2 添加log4j的依赖

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-log4j</artifactId>
   <version>1.3.0.M1</version>
</dependency>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.16</version>
</dependency>

猜你喜欢

转载自blog.csdn.net/qq_36209121/article/details/78815038