Sentry-java: Error configuring Sentry appender using logback

Created on 19 Jun 2017  路  5Comments  路  Source: getsentry/sentry-java

Getting an error when configuring Sentry appender based on:
https://docs.sentry.io/clients/java/modules/logback/

logback.xml:

    ...
    <appender name="sentry" class="io.sentry.logback.SentryAppender">
      <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>WARN</level>
        </filter>
    </appender>
    ...
    ...
    <root>
        <level value="INFO" />
        <appender-ref ref="consoleAppender" />
        <appender-ref ref="sentry" />
    </root> 

Exception thrown:

09:41:49.526 [main] ERROR  o.s.boot.SpringApplication.reportFailure:815  - Application startup failed
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [io.sentry.logback.SentryAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type io.sentry.logback.SentryAppender
ERROR in ch.qos.logback.core.joran.spi.Interpreter@27:70 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type io.sentry.logback.SentryAppender
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [sentry]. Did you define it below instead of above in the configuration file?
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.

Tried both versions 1.0.0 and 1.1.0

Most helpful comment

Oh, yeah, from the sentry-logback documentation:

<dependency>
    <groupId>io.sentry</groupId>
    <artifactId>sentry-logback</artifactId>
    <version>1.1.0</version>
</dependency>

You need to use the sentry-logback dependency (which will pull in sentry transitively).

All 5 comments

Can you turn on DEBUG logging and paste anything from io.sentry.* (or just enable it for that package)?

I just re-checked that this example works on 1.0.0 and 1.1.0. So yeah, I think we'll have to check the DEBUG logs to understand what is different about your setup.

the issue seems to be a ClassNotFoundException

Caused by: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type io.sentry.logback.SentryAppender
    at  at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:69)
    at  at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:45)
    at  at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:34)
    at  at ch.qos.logback.core.joran.action.AppenderAction.begin(AppenderAction.java:52)
    at  ... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: io.sentry.logback.SentryAppender
    at  at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at  at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:56)
    at  ... 24 common frames omitted

Indeed, when I go to the downloaded sentry-1.1.0.jar , the specific class is not there.

Am I missing something so obvious here? (there is not even a io.sentry.logback package in the jar)

Oh, yeah, from the sentry-logback documentation:

<dependency>
    <groupId>io.sentry</groupId>
    <artifactId>sentry-logback</artifactId>
    <version>1.1.0</version>
</dependency>

You need to use the sentry-logback dependency (which will pull in sentry transitively).

I was missing something so obvious at the end :)

Sorry, my bad, and thank you for pointing this out.

Was this page helpful?
0 / 5 - 0 ratings