Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Jena 3.15.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:
- Use whatever mechanism the logging provider has for initialization. (system properties usually).
- 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.