Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

epublib-core could avoid sl4j-simple binding #134

Open
nikhilsilveira opened this issue Jun 9, 2020 · 0 comments
Open

epublib-core could avoid sl4j-simple binding #134

nikhilsilveira opened this issue Jun 9, 2020 · 0 comments

Comments

@nikhilsilveira
Copy link

Using epublib-core in a springboot application causes two issues:

  1. a warning: Class Path Contains Multiple SLF4J Bindings -- this can be ignored
  2. IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath

The problem seems to me, the slf4j-simple binding (provider) inherited from the parent pom.
Considering the core library intention as a client, it might be better served by just using the sl4j-api and omitting the binding (provider). From baeldung:

It is worth noting that embedded components such as libraries or frameworks should never declare a dependency on any SLF4J binding. This is because when a library declares a compile-time dependency on an SLF4J binding, it imposes that binding on the end-user. Obviously, this negates SLF4J's basic purpose. Consequently, they should only depend on the slf4j-api library.

A commonly proposed solution is to add to your gradle build file:

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'
    }

However, this disables logging configuration for the entire app.
On the other hand, this doesn't seem to work:

    compile ('nl.siegmann.epublib:epublib-core:4.0') {
        exclude group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
        exclude group: 'ch.qos.logback', module: 'logback-classic'
    }

The solution that worked for me was to:

  • remove the sl4j-simple dependency from the parent pom and the epublib-core pom files
    • build the jar again and use it.

Now it no longer has a conflict and spring boot logging will work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant