简体   繁体   中英

Spring Boot Maven Plugin missing stack trace

I recently updated a code base from Spring Boot 1.2.7 to v2.0.0. For the most part, this was successful but I noticed an undesired change in functionality wherein stack traces are missing when failures occur during startup. I am uncertain whether I missed something, this is intended, or if a bug was introduced between these two versions.

The project uses the Spring Boot Maven Plugin. When JVM arguments are included and if the app fails to start (possibly due to incorrect Spring wiring, port already in use, etc.), a stack trace will not be logged to explain why the app failed to start. If the JVM arguments are omitted, the stack trace will be included in the logs. Prior to the upgrade, the stack trace was included when JVM arguments were used.

As the plugin forks the JVM when JVM arguments are included and the application is not otherwise forking the JVM, I wonder if it has something to do with that.

To help with this issue, I started to pull together a stripped-down version of the POM as well as a "main" class. While the project is using Logback for logging, during the process of creating a simplified version I found that Log4J was transitively included via several other libraries. When I removed the Log4J dependencies from the classpath, logging during startup worked as expected.

The inclusion of Log4J in the project pre-dates the upgrade of Spring Boot version. So, there is certainly a missing piece here as I don't know what changed to cause the breakage. However, the path forward seems clear as Log4J should not be included in the project. I will be happy to accept any other answers with more information on what may have changed to cause the differing behavior but, if not, I will consider this resolved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM