简体   繁体   中英

No log4j library found after updating spring boot from 1.3.5 to 1.5.17

I upgraded spring boot from 1.3.5 to 1.5.17 and the log4j library is no longer found. The error says Error:(10, 24) java: package org.apache.log4j does not exist. Here is my pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.17.RELEASE</version>
    <relativePath />
</parent>
<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
     <groupId>org.springframework.kafka</groupId>
     <artifactId>spring-kafka</artifactId>
     <version>1.3.8.RELEASE</version>
</dependency>
<dependency>
     <groupId>org.apache.kafka</groupId>
     <artifactId>kafka_2.10</artifactId>
     <version>0.8.2.2</version>
 <exclusions>
    <exclusion>
      <groupId>org.apache.zookeeper</groupId>
      <artifactId>zookeeper</artifactId>
    </exclusion>
    <exclusion>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Since Spring Boot 1.4, support for log4j 1.x has been dropped, as can be seen in the release notes of Spring boot 1.4 :

Log4j 1 support has been removed following Apache EOL announcement .

They recommend to upgrade to log4j 2.x, which can be done by using the following dependency:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM