Recently I am upgrading from spring boot 1.5.4 to spring boot 2.2.4. After upgrading to spring boot 2.2.4, I am getting following compilation error

[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.783 s [INFO] Finished at: 2020-02-02T14:42:44+05:30 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project : Compilation failure: Compilation failure: package org.apache.log4j does not exist

Observing that

https://github.com/spring-projects/spring-boot/blob/v1.5.4.RELEASE/spring-boot-starters/spring-boot-starter-logging/pom.xml - has the following maven dependency <dependency> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> </dependency>

But, https://github.com/spring-projects/spring-boot/blob/v2.2.4.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-logging/pom.xml not contains it.

In dependency hierarchy for spring-boot 1.5.4, it is shown as follows.

springboot log4j-over-slf4j not exists in spring-boot-starter-logging/pom.xml

Please add this dependency in Spring-boot 2.x

Comment From: wilkinsona

Thanks for the suggestion, but its removal was intentional. Please see https://github.com/spring-projects/spring-boot/issues/11148 for details. Log4j 1 was declared end-of-life in August 2015. Any code the depends upon it should be updated to use an alternative logging API.

Comment From: larrywest

@ShriprasadM IMHO, it's more maintainable to write to the slf4j API and completely avoid code references to the back-end implementation (logback, log4j2).

Logback is what spring-boot-starter-logging uses, but if you prefer log4j2, you can replace that as outlined here (to pick the first article that Google returned).

HTH

PS: Both back-end implementations have many improvements over log4j 1.x. If you do more than cursory logging, it's worth scanning the documentation and/or release notes. For example, Log4j 2.13.0 allows "... Spring Boot application properties to be accessed in the Log4j 2 configuration".