Loggerfactory is not a logback loggercontext but logback is on the classpath. either remove logback or the competing implementation

Error: loggerfactory is not a logback loggercontext

This error occurs when you try to use Logback logging framework, but there is another logging framework present in your classpath that conflicts with Logback.

To fix this issue, you have two options:

  1. Remove the competing logging implementation from your classpath
  2. You need to identify the other logging framework that is conflicting with Logback and remove it from your project’s dependencies. This can be done by locating the dependency in your build configuration file (e.g., pom.xml in Maven) and removing the corresponding entry. For example, if you have Apache Commons Logging as a dependency, you can remove it with the following XML code snippet:

          <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <!-- Remove this line -->
            <version>1.2</version>
          </dependency>
        
  3. Remove Logback and use the competing logging framework
  4. If you prefer to use the competing logging framework and remove Logback, you can do so by removing the Logback dependencies from your project and replacing them with the dependencies for the other logging framework. Make sure to also adjust your logging configurations and code accordingly.

Here’s an example of a Maven dependency exclusion to remove Apache Commons Logging, assuming it is causing the conflict:

    <dependency>
      <groupId>your-library-group-id</groupId>
      <artifactId>your-library-artifact-id</artifactId>
      <version>your-library-version</version>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  

Similar post

Leave a comment