Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the root cause of Log4JLogger' cannot be found or is not useable?

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)
like image 952
Debajyoti Roy Avatar asked May 21 '12 20:05

Debajyoti Roy


2 Answers

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

like image 165
Max Robbertze Avatar answered Oct 07 '22 22:10

Max Robbertze


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.

like image 40
Mario.Cadiz Avatar answered Oct 07 '22 23:10

Mario.Cadiz