In my Spring boot 2 project:
In build.gradle
:
dependencies {
implementation \'com.google.code.gson:gson:2.7\'
imple
Spring boot 2.3.0.RELEASE
version, support Log4j2 natively, for logging configuration if it is on the classpath. In this case, you can simply remove other log4j dependencies.
In other case, if you use the starters for assembling dependencies, you have to exclude Logback and then include log4j 2 instead:
You can do like that with Gradle:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-log4j2'
}
configurations {
all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
Or with Maven:
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-logging
org.springframework.boot
spring-boot-starter-log4j2
More information on the official documentation: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-configure-log4j-for-logging