Spring Boot 2.2.2.RELEASE with logstash-logback-encoder Versions > 5.2 service fails with System.Exit 0
See original GitHub issueHi, we have tried to use Spring Boot 2.2.2.RELEASE with logstash-logback-encoder:
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>6.3</version>
</dependency>
together with JSON formatted structured logging.
application.properties is working otherwise with non-json logging.
logback-spring.xml looks something like this:
<springProfile name="local">
<property resource="application.properties" />
<contextName>${spring.application.name}</contextName>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<contextName>
<fieldName>appName</fieldName>
</contextName>
<threadName>
<fieldName>appThread</fieldName>
</threadName>
<timestamp>
<fieldName>appTimestamp</fieldName>
<timeZone>Europe/Stockholm</timeZone>
</timestamp>
<loggerName>
<fieldName>appLogger</fieldName>
</loggerName>
<logLevel>
<fieldName>appLogLevel</fieldName>
</logLevel>
<callerData>
<classFieldName>callerClass</classFieldName>
<methodFieldName>callerMethod</methodFieldName>
<fileFieldName>callerFile</fileFieldName>
<lineFieldName>callerLine</lineFieldName>
</callerData>
<mdc/>
<arguments>
<includeNonStructuredArguments>false</includeNonStructuredArguments>
</arguments>
<stackTrace>
<fieldName>stack</fieldName>
</stackTrace>
<message>
<fieldName>msg</fieldName>
</message>
</providers>
</encoder>
</appender>
<root>
<appender-ref ref="STDOUT"/>
</root>
</springProfile>
</configuration>
In all cases where the logstash-logback-encoder version is greater than 5.2 we see that our Spring Boot services fails to start and exits with status 0.
Anyone else experiencing similar problems?
Issue Analytics
- State:
- Created 4 years ago
- Comments:12
Top Results From Across the Web
Spring Boot 2.2.2.RELEASE with logstash-logback-encoder ...
RELEASE with logstash-logback-encoder Versions > 5.2 service fails ... that our Spring Boot services fails to start and exits with status 0.
Read more >Spring Cloud Sleuth Reference Documentation
Spring Cloud Sleuth is able to trace your requests and messages so that you can correlate that communication to corresponding log entries. You...
Read more >Springfox swagger not working in spring boot 2.2.0
I am using spring-boot 2.2.2.RELEASE and there was no issue with spring-core and swagger. Below import was the culprit
Read more >Failed To Instantiate Type Net.Logstash.Logback.Appender ...
RELEASE with logstashlogbackencoder Versions 5.2 service fails with System.Exit 0. Hi we have tried to use Spring Boot 2.2.2.
Read more >Cloud Native Core Licensing Information User Manual
Provider Component (s) Licensing Information
Apache 2.0 akka‑cluster‑sharding 2.6.7 APACHE 2.0 ‑See Appendix E
Ansible, Inc. Ansible 2.7.9‑1
Eclipse Foundation AspectJ 1.9.5
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @duclm2609 !
While debugging your example application with logstash-logback-encoder >= v5.3, I found the following exception occurring during startup:
Starting with logstash-logback-encoder v5.3, automatic discovery of jackson modules was enabled by default. With logstash-logback-encoder <= 5.2, the problem does not occur because automatic discovery of jackson modules does not occur by default.
The root cause is a bug in liquibase reported as CORE-3542. Basically the liquibase-core jar contains a service definition file (
META-INF/services/com.fasterxml.jackson.databind.Module
) that points to thecom.fasterxml.jackson.module.jaxb.JaxbAnnotationModule
class, which is not on the classpath. When jackson tries to load all modules via java’sServiceLoader
, aClassNotFoundException
occurs, which is then translated into theServiceConfigurationError
mentioned above.There are three possible solutions to get this to work with the latest logstash-logback-encoder:
A) Don’t use
org.liquibase:liquibase-core
until CORE-3542 is fixed, since that jar has an incorrect service loader configuration file.OR
B) Disable automatic jackson module discovery (as mentioned here) for the encoder/layout.
For example:
OR
C) Add the dependency that contains the
com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule
class (which allows the automatic discovery to work properly):@duclm2609, Any one of these solutions will allow your example project to work with the latest logstash-logback-encoder.
@englishbobster and @PatrickHuetter , can you see if these solutions address your problems as well? I’m going to assume that it is the same problem. I’ll close this issue if I don’t hear back after a while.
@philsttr thanks for the analysis and an explanation