Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1912

LogCtl.<init> loads Log4j2 code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Jena 3.15.0
    • Jena 3.16.0
    • None
    • None

    Description

      This is a problem in applications that choose to use a different logging provider.

      If LogCtl (a collection of static methods) is even just touched, before any static method call, and with org.slf4j:slf4j-jdk14 as logging provider, there is an exception:

      Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/config/ConfigurationFactory
      	at dev.ReportLogCtl.main(ReportLogCtl.java:62)
      Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.core.config.ConfigurationFactory
      	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
      	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
      	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
      	... 1 more
      

      I don't know why ConfigurationFactory is being loaded. It isn't in a static member, only one static method. The same code for log4j1 did not have the same problem.

      LogCtl is not normally used. I came across this in RDF delta where the logging provider for testing is JUL andthe test use LogCtl to enable/disable loggers during tests.

      Rather than a point fix, the code should be changed:

      1. Use whatever mechanism the logging provider has for initialization. (system properties usually).
      2. Move the provider specifc code to another place so it is not loaded as part fo LogCtl class initialization.

      Athe same time, switch to a single LogCtl.setLogging which installs some basic default setup if there isn't the preferred setup for the logging provider.

      Attachments

        Activity

          People

            andy Andy Seaborne
            andy Andy Seaborne
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h