Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LoggerFactory is not a Logback LoggerContext but Logback is on the classpath

I think some module in spring-boot-starter-security is conflict with log4j, but I don't know which one.

my gradle dependence is as following:

compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-security"){
    exclude module: "spring-boot-starter-logging"
}

compile "org.apache.logging.log4j:log4j-api"
compile "org.apache.logging.log4j:log4j-core"
compile "org.apache.logging.log4j:log4j-slf4j-impl"
compile('org.apache.poi:poi:3.10.1')
compile('org.apache.poi:poi-ooxml:3.10.1')
testCompile("junit:junit")
like image 715
newbie Avatar asked Jun 11 '15 22:06

newbie


3 Answers

Same solution for maven:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
    <version>1.5.1.RELEASE</version>
    <exclusions>
        <exclusion>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </exclusion>
    </exclusions>
</dependency>
like image 152
ufukomer Avatar answered Oct 15 '22 10:10

ufukomer


i figured out

compile("org.springframework.boot:spring-boot-starter-security"){
    exclude module: "spring-boot-starter-logging"
    exclude module: "logback-classic"
}
compile("org.springframework.boot:spring-boot-starter-thymeleaf"){
    exclude module: "logback-classic"
}
like image 43
newbie Avatar answered Oct 15 '22 10:10

newbie


The problem for me went on with: Either remove Logback or the competing implementation class org.apache.logging.slf4j.Log4jLoggerFactory loaded from log4j-slf4j-impl-2.12.0.jar

I added

configurations {
    all {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
        exclude group: 'ch.qos.logback', module: 'logback-classic'
        exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j'
    }
}

to my gradle.build and also refreshed all project dependencies with the latest versions and the problem resolved.

like image 28
rupweb Avatar answered Oct 15 '22 10:10

rupweb