I have commons-logging.jar (v1.0.4) and log4j-1.2.8.jar in the classpath and getting following run-time error:
Caused by: org.apache.commons.logging.LogConfigurationException: User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable.
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:874)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:604)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:336)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:310)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
There is an answer here Commons-logging with log4j2
Include the library: log4j-jcl
See also:
https://logging.apache.org/log4j/2.x/faq.html#which_jars
This error seems to be pretty generic. To get more details, start up the JVM with this option:
-Dorg.apache.commons.logging.diagnostics.dest=STDOUT
In my case, found some missing dependencies.
[LogFactoryImpl@929338653 from sun.misc.Launcher$AppClassLoader@1442407170] Attempting to instantiate 'org.apache.commons.logging.impl.Log4JLogger'
[LogFactoryImpl@929338653 from sun.misc.Launcher$AppClassLoader@1442407170] Trying to load 'org.apache.commons.logging.impl.Log4JLogger' from classloader sun.misc.Launcher$AppClassLoader@1442407170
[LogFactoryImpl@929338653 from sun.misc.Launcher$AppClassLoader@1442407170] Class 'org.apache.commons.logging.impl.Log4JLogger' was found at 'jar:file:/home/mcadiz/NetBeansProjects/LogFilter/dist/lib/commons-logging-1.2.jar!/org/apache/commons/logging/impl/Log4JLogger.class'
[LogFactoryImpl@929338653 from sun.misc.Launcher$AppClassLoader@1442407170] The log adapter 'org.apache.commons.logging.impl.Log4JLogger' is missing dependencies when loaded via classloader sun.misc.Launcher$AppClassLoader@1442407170: org/apache/log4j/Priority
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.apache.commons.logging.LogConfigurationException: User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable.
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:804)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:541)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:292)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:269)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
at com.oracle.logfilter.LogEntry.<clinit>(LogEntry.java:19)
Adding the log4j.jar to the classpath fixed the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With