Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-13212

Remove hard dependency on Logback

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Workaround
    • None
    • Legacy/Core
    • None
    • Normal

    Description

      Hi,

      Our application is using Log4J2, SpringBoot and cassandraunit. We just upgraded to use cassandra-all version 3.0.10 (to approximately match the DataStax version wer're using) and excluded the logback-classic and logback-core dependencies from this dependency.

      However when I try to run an embedded Cassandra unit test, it always fails with the following error:

      Exception (java.lang.NoClassDefFoundError) encountered during startup: ch/qos/logback/core/Context
      java.lang.NoClassDefFoundError: ch/qos/logback/core/Context
      at org.apache.cassandra.service.StorageService.initServer(StorageService.java:604)
      at org.apache.cassandra.service.StorageService.initServer(StorageService.java:558)
      at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:346)
      at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:568)
      at org.cassandraunit.utils.EmbeddedCassandraServerHelper$1.run(EmbeddedCassandraServerHelper.java:133)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.Context
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      ... 8 more

      I looked at the source code of StorageService and it seems like it is invoking Logback-specific classes directly, instead of SLF4J ones. This code seems to have been introduced by CASSANDRA-5883.

      I currently don't see a logback-to-slf4j bridge so seems it seems our options are to not use Cassandra (which is not possible) or to try to create a dummy bridge to route logback calls to slf4j (which then goes to Log4j2).

      Any particular reason why the Logback classes are invoked directly instead through SLF4J?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              CarthageKing Michael Calderero
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: