Search code examples
javagoogle-cloud-platformlogbackstackdrivergoogle-cloud-logging

Stackdriver Logback appender stops application


I have a problem using google-cloud-logging-logback library to write logs to Stackdriver. When I add appender to logback configuration then application does not start and just stops with logs below:

09:34:37,755 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 10 seconds
09:34:37,769 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
09:34:37,769 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [console]
09:34:37,772 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:34:37,774 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.google.cloud.logging.logback.LoggingAppender]
09:34:37,785 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [cloud]
09:34:38,027 |-WARN in Logger[org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator] - No appenders present in context [default] for logger [org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator].

As you can see, there are no errors, the application just stops when trying to initialize google appender. This is my appender configuration:

<appender name="cloud" class="com.google.cloud.logging.logback.LoggingAppender">
    <!-- Optional : filter logs at or above a level -->
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
        <level>DEBUG</level>
    </filter>
    <resourceType>global</resourceType> <!-- Optional : default: auto-detected, fallback: global -->
    <flushLevel>INFO</flushLevel> <!-- Optional : default ERROR -->
</appender>

And here are my logback dependencies:

compile 'ch.qos.logback:logback-core:1.2.3'
compile 'ch.qos.logback:logback-access:1.2.3'
compile 'ch.qos.logback:logback-classic:1.2.3'
compile 'com.google.cloud:google-cloud-logging-logback:0.116.0-alpha'

Can you help me find what is wrong with this or how to show an error that makes application stop?


Solution

  • I created a different project where I included only logging to Google and this time I got an error message.

    The cause of the problem was a wrong verion of guava library, used version was too old(<0.20) and it caused NoSuchMethod exceptions.

    Too old version of guava library was actually an intellij issue because of caching, application started fine when ran directly from IntelliJ but failed during logback initialization when started from fatJar form. Invalidating cache in IntelliJ helped.