开发者

What is likely cause of Android runtime exception "No suitable Log implementation" related to logging in 3rd-party jar?

开发者 https://www.devze.com 2022-12-26 03:37 出处:网络
I am creating an Android app that includes a third party jar.That third party jar utilizes internal logging that is failing to initialize when I run the app, with this error: \"org.apache.commons.logg

I am creating an Android app that includes a third party jar. That third party jar utilizes internal logging that is failing to initialize when I run the app, with this error: "org.apache.commons.logging.LogConfigurationException: No suitable Log implementation".

The 3rd party jar appears to be using org.apache.commons.logging and to depend on log4j, specifically log4j-1.2.14.jar. I have packaged the log4j jar into the Android app. The third party jar was packaged with a log4j.xml configuration file, which I have tried packaging into the app as an XML resource (and also as a raw resource).

The "No suitable Log implementation" error message is not very descriptive, and I have no immediate familiarity with Java logging. So I am looking for likely causes of the problem (what class or configuration resources might I be missing?) or for some debugging technique that will result in a different error message that is more explicit about the problem. I do not have access to source code for the 3rd party jar.

Here is the exception stack trace. When I run the app, I get the following exception as soon as one of the third party jar classes attempts to initialize its internal logging.

DEBUG/AndroidRuntime(15694): Shutting down VM
WARN/dalvikvm(15694): threadid=3: thread exiting with uncaught exception (group=0x4001b180)
ERROR/AndroidRuntime(15694): Uncaught handler: thread main exiting due to uncaught exception
ERROR/AndroidRuntime(15694): java.lang.ExceptionInInitializerError
ERROR/AndroidRuntime(15694): Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log implementation
ERROR/AndroidRuntime(15694):     at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:842)
ERROR/AndroidRuntime(15694):     at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:601)
E开发者_C百科RROR/AndroidRuntime(15694):     at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:333)
ERROR/AndroidRuntime(15694):     at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:307)
ERROR/AndroidRuntime(15694):     at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645)
ERROR/AndroidRuntime(15694):     at org.apache.commons.configuration.ConfigurationFactory.<clinit>(ConfigurationFactory.java:77)


It may help to study the logic around org.apache.commons.logging.impl.LogFactoryImpl

There's probably a way of injecting a Log implementation.

http://google.com/codesearch/p?hl=en#CskViEIa27Y/src/org/apache/commons/logging/impl/LogFactoryImpl.java&l=762

http://google.com/codesearch/p?hl=en#CskViEIa27Y/src/org/apache/commons/logging/impl/LogFactoryImpl.java&l=883

0

精彩评论

暂无评论...
验证码 换一张
取 消