Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Failed to instantiate type ch.qos.logback.ext.loggly.LogglyAppender in Android #36

Open
keyuraashra opened this issue Aug 12, 2015 · 5 comments
Labels

Comments

@keyuraashra
Copy link

I am working on Android native app and I have successfully integrated logback with LOGCAT and now trying to integrate it with loggly but I am getting some issue with it and I thought this is the best place to get guidance/resolution of it.

build.gradle :-

compile 'org.logback-extensions:logback-ext-loggly:0.1.2'

logback.xml :-

<configuration>

    <appender name="LOGCAT" class="ch.qos.logback.classic.android.LogcatAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="LOGGLY" class="ch.qos.logback.ext.loggly.LogglyAppender">
        <endpointUrl>
            https://logs-01.loggly.com/inputs/d6415bd0-88f4-407d-8e89-bd9c4c95ef6f/tag/logback
        </endpointUrl>
        <encoder>
            <pattern>%d{"ISO8601", UTC} %p %t %c{0}.%M - %m%n</pattern>
        </encoder>
    </appender>

    <logger name="co.pointwise.android.sdk" level="debug" additivity="false">
        <appender-ref ref="LOGGLY" />
    </logger>

    <root level="debug">
        <appender-ref ref="LOGCAT" />
    </root>
</configuration>

Full Error Log :-

08-12 09:19:21.663  27034-27034/co.librarytest I/art﹕ Late-enabling -Xcheck:jni
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ 09:19:22,511 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [assets/logback.xml] at [assets/logback.xml]
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ 09:19:22,618 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ 09:19:22,619 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.android.LogcatAppender]
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ 09:19:22,622 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [LOGCAT]
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ 09:19:22,629 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ 09:19:22,680 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.ext.loggly.LogglyAppender]
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ 09:19:22,681 |-ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [ch.qos.logback.ext.loggly.LogglyAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.ext.loggly.LogglyAppender
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ at ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.ext.loggly.LogglyAppender
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(Unknown Source)
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(Unknown Source)
08-12 09:19:22.707  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.action.AppenderAction.begin(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.spi.Interpreter.startElement(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.spi.Interpreter.startElement(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.spi.EventPlayer.play(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.classic.util.ContextInitializer.autoConfig(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.impl.StaticLoggerBinder.init(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.impl.StaticLoggerBinder.<clinit>(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.LoggerFactory.bind(LoggerFactory.java:129)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:302)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:276)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at co.pointwise.android.sdk.db.JournalContentProvider.<init>(JournalContentProvider.java:30)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.reflect.Constructor.newInstance(Native Method)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.Class.newInstance(Class.java:1572)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread.installProvider(ActivityThread.java:5039)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread.installContentProviders(ActivityThread.java:4646)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread.access$1500(ActivityThread.java:148)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at android.os.Handler.dispatchMessage(Handler.java:102)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at android.os.Looper.loop(Looper.java:135)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread.main(ActivityThread.java:5312)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.reflect.Method.invoke(Native Method)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.reflect.Method.invoke(Method.java:372)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ Caused by: java.lang.ClassNotFoundException: Didn't find class "ch.qos.logback.ext.loggly.LogglyAppender" on path: DexPathList[[zip file "/data/app/co.librarytest-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   ... 33 common frames omitted
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ 09:19:22,681 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@8:78 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.ext.loggly.LogglyAppender
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.ext.loggly.LogglyAppender
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.action.AppenderAction.begin(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.spi.Interpreter.startElement(Unknown Source)
08-12 09:19:22.708  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.spi.Interpreter.startElement(Unknown Source)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.spi.EventPlayer.play(Unknown Source)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(Unknown Source)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(Unknown Source)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(Unknown Source)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.classic.util.ContextInitializer.autoConfig(Unknown Source)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.impl.StaticLoggerBinder.init(Unknown Source)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.impl.StaticLoggerBinder.<clinit>(Unknown Source)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.LoggerFactory.bind(LoggerFactory.java:129)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:302)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:276)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at co.pointwise.android.sdk.db.JournalContentProvider.<init>(JournalContentProvider.java:30)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.reflect.Constructor.newInstance(Native Method)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.Class.newInstance(Class.java:1572)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread.installProvider(ActivityThread.java:5039)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread.installContentProviders(ActivityThread.java:4646)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread.access$1500(ActivityThread.java:148)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at android.os.Handler.dispatchMessage(Handler.java:102)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at android.os.Looper.loop(Looper.java:135)
08-12 09:19:22.709  27034-27034/co.librarytest I/System.out﹕ at   at android.app.ActivityThread.main(ActivityThread.java:5312)
08-12 09:19:22.710  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.reflect.Method.invoke(Native Method)
08-12 09:19:22.710  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.reflect.Method.invoke(Method.java:372)
08-12 09:19:22.710  27034-27034/co.librarytest I/System.out﹕ at   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
08-12 09:19:22.710  27034-27034/co.librarytest I/System.out﹕ at   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
08-12 09:19:22.710  27034-27034/co.librarytest I/System.out﹕ Caused by: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.ext.loggly.LogglyAppender
08-12 09:19:22.711  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(Unknown Source)
08-12 09:19:22.711  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(Unknown Source)
08-12 09:19:22.711  27034-27034/co.librarytest I/System.out﹕ at   at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(Unknown Source)
08-12 09:19:22.711  27034-27034/co.librarytest I/System.out﹕ at   ... 30 common frames omitted
08-12 09:19:22.711  27034-27034/co.librarytest I/System.out﹕ Caused by: java.lang.ClassNotFoundException: Didn't find class "ch.qos.logback.ext.loggly.LogglyAppender" on path: DexPathList[[zip file "/data/app/co.librarytest-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
08-12 09:19:22.711  27034-27034/co.librarytest I/System.out﹕ at   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-12 09:19:22.711  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-12 09:19:22.711  27034-27034/co.librarytest I/System.out﹕ at   at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
08-12 09:19:22.711  27034-27034/co.librarytest I/System.out﹕ at   ... 33 common frames omitted

Any idea what is going wrong here?

@tony19
Copy link
Contributor

tony19 commented Aug 12, 2015

For starters, it looks like logback-extensions isn't in your classpath based on:

Caused by: java.lang.ClassNotFoundException: Didn't find class "ch.qos.logback.ext.loggly.LogglyAppender" on path: DexPathList[[zip file "/data/app/co.librarytest-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

Can you add the library to your classpath and retest?

@keyuraashra
Copy link
Author

I am testing with Jar now, just want to add one more thing which might help. I am working on library project and I am including AAR file in main project and I have integrated logback in library project. Is there anything which cause the issue in this case as i can see its printing on base.apk with Dex?

proguard:-
-keep class ch.qos.** { ; }
-keep class org.slf4j.
* { ; }
-keepattributes *Annotation

@manvinderKalsi
Copy link

Did this ever worked. I am having a hard time getting this configured in my application.
Have to do it through in code statements and then getting error: android.os.NetworkOnMainThreadException

Is there anything i am missing?

@grote
Copy link

grote commented Oct 23, 2016

Adding this to my proguard file gets rid of the error:

-keep class ch.qos.logback.classic.android.LogcatAppender

@vijaycaimi
Copy link

worked for me by adding new version of logback

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants