score:68
according to spring documentation (as pointed out by simon), we want to exclude the "spring-boot-starter-logging" module from all libraries, not just from "spring-boot-starter-web".
configurations {
...
all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
...instead of...
dependencies {
...
implementation('org.springframework.boot:spring-boot-starter') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
i myself had the same problem and solved it with this solution.
score:0
even after correcting classpath, i had the same problem in sts and gradle 'refresh all' solved it.
score:0
the best way to solve this would be to run gradle dependencies, and identify where the log4j-to-slf4j is coming from, and then exclude this module in build.gradle
score:1
i excluded spring boot logging from build.gradle but issue was still occurring. it got resolved by removing org.apache.logging.log4j/log4j-slf4j-impl/2.12.1
from .classpath
score:2
from the error logs decide which project to exclude.
e.g for a error msg like this: caused by: org.apache.logging.log4j.loggingexception: log4j-slf4j-impl cannot be present with log4j-to-slf4j i've used the gradle exclude:
configurations.all { exclude group: 'org.apache.logging.log4j'
}
score:30
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:
<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>
<dependency>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-starter-log4j2</artifactid>
</dependency>
more information on the official documentation: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-configure-log4j-for-logging
Source: stackoverflow.com
Related Query
- Spring boot + slf4j + log4j + class org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to class
- Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j-impl cannot be present with log4j-to-slf4j
- Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set.
- Spring boot - Cannot turn off logging
- Caused by: org.eclipse.jgit.api.errors.RefNotFoundException: Ref master cannot be resolved
- Caused by: java.io.FileNotFoundException: class path resource [application.properties] cannot be opened because it does not exist
- Spring boot , apache camel and hawtio: cannot send message to endpoint
- Apache Ignite with Spring Boot CrudRepo cannot be initialized
- Cannot use Apache Commons FileUpload with Spring Boot multipart.resolve-lazily
- Spring Boot SLF4J Logging performance
- Cannot create a secure XMLInputFactory when calling Apache CXF Client in spring boot application
- Spring Boot Logging Properties vs Log4J 2 Properties
- caused by: org.springframework.expression.spel.spelevaluationexception: el1007e: property or field 'yyy' cannot be found on null
- Spring boot slf4j + log4j2 logging blocked by logback dependency
- Spring Boot & Slf4j 2 Http request metadata logging interceptor?
- Spring boot logging with log4j - how do I ENABLE spring boot log entries?
- Spring Boot slf4j Logger in @Service not logging
- SLF4J AND LOG4J binding exception in spring boot app with ignite dependency
- Cannot run my test with Apache CXF and SpringBoot
- Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
- Cannot connect to Tomcat web socket behind Apache
- Fail to Integrate log4j into spring-boot - Class path contains multiple SLF4J bindings
- Spring autowiring: Caused by: java.lang.IllegalArgumentException: Cannot set a null TableModel
- Spring Boot log4j ClassPath contains multiple SLF4J bindings
- Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'com.sportswin.soa.spark.controller.ISparkGameUserController' method
- Cannot change REST context path in Apache Camel 3.14.0 Spring Boot app
- SpringBoot - Logging environment value cannot be opened and will be ignored
- Springboot - SLF4J - logging pattern
- Strange bootloader casting issue caused by different packages: "class [Ljava.lang.Object; cannot be cast to class ([Ljava.lang.Object; "
- Hibernate Jboss logging and Log4j CVE Vulnerability
More Query from same tag
- Accessing Job Parameters Spring Batch
- Getting 400 bad Request with Tomcat 8.5.9
- Gradle set name for jar created with spring-boot's assemble
- Is there a way to connect to a different host than localhost in application.properties?
- Dependencies in pom.xml profiles
- Spring Security Authorization Code not able to fetch token after getting user consent
- Do not want to load application.yml when testing with Spring Boot
- Does every job call in Spring Batch open a new database connection pool?
- logback.xml missing in project created with STS and Spring boot
- Same Data applied across all Beans of same type while creating a list of beans with different data
- Using Citrus to mock SFTP and Kafka for Integration Testing Spring-Boot apache-camel xml based routes?
- IntelliJ doesn't recognize Kotlin JPA plugin
- Testing Multipartfile in spring boot Nullpointerexception due to MockMultipartFile
- Use Form to send Email in Spring Boot using Thymeleaf
- How can I use ID(arguments) to different GetMappings
- Spring RestTemplate throwing 403 Forbidden after hitting API
- How to use JpaMessageIdRepository in Spring Boot?
- Why Use PathVariable instead of PathParam?
- Ribbon MaxAutoRetries properties is not working
- How to invoke Spring Integration SFTP by Azure Functions/Spring Cloud Function
- accessing resources in next steps spring batch
- JSON deserealization problems while moving from springboot 2.0.2 to 2.2.2
- Unable to get HashMap value in Thymeleaf with long key
- Class Not Found Exception org//h2//Driver
- html and thymeleaf not working properly with svg element on html page
- Spring Boot start the application with configurations check
- Mockito: To test that a returned String is under a given length
- Is there a way to get all the static fields and its values from different class dynamically?
- How to solve this Spring Boot problem when I want to use a Repository
- How to migrate from Vaadin 8 to Vaadin 20 without SpringBoot but with a embedded Tomcat?