Search code examples
spring-bootpom.xmllogback

"net.logstash.logback.encoder.LogstashEncoder" object is not assignable to a "ch.qos.logback.core.Appender" variable. when upgrading to spring boot 2


I've upgrade from spring boot 1.5.0 to 2.0.0 and I got this error :

ERROR in ch.qos.logback.core.joran.util.PropertySetter@6f01b95f - A "net.logstash.logback.encoder.LogstashEncoder" object is not assignable to a "ch.qos.logback.core.Appender" variable.

It seems one library needs logback-classic 1.0.13 and spring boot 2.0.0 imports logback-classic 1.2 I've tried to excluse from spring boot this library but it seems the application couldn't start without logback-classic... enter image description here


Solution

  • There was an issue in Logback similar to the one you describe. It was fixed in version 1.2.5.

    You can try to set the logback version property in your POM to make the Spring dependency management use that, i.e.

    <properties>
        <logback.version>1.2.5</logback.version>
        ...
    </properties>
    

    You might also need to exclude all transitive logback dependencies from your custom lib dependencies if there are any.

    If that doesn't help, instead try to add the logback dependency explicitly to your POM to make use of Maven's nearest definition logic.

    Run mvn dependency:tree to check that the proper versions are picked up.