spring-cloud-commons icon indicating copy to clipboard operation
spring-cloud-commons copied to clipboard

Startup info not logged when bootstrap is being used

Open fedup41 opened this issue 3 years ago • 1 comments

The startup info messages should appear regardless of the existence of a bootstrap being utilitzed.

This code in SpringApplication#prepareContext inhibits the logStartupInfo(boolean).

        if (this.logStartupInfo) {
            this.logStartupInfo(context.getParent() == null);
            this.logStartupProfileInfo(context);
        }

context.getParent() is the bootstrap context when this dependency is included. It is null otherwise.

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-kubernetes-fabric8-config</artifactId>
        </dependency>

I am using

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.8</version>
        <relativePath/>
    </parent>

with these related versions

        <spring-cloud-gcp.version>3.2.1</spring-cloud-gcp.version>
        <spring-cloud.version>2021.0.0</spring-cloud.version>

spring-cloud-starter-kubernetes-fabric8-config ends up being version 2.1.0

Example, minimal project. StartupInfoNotShowing.zip

Apparently, it is due to this code

fedup41 avatar Jul 22 '22 17:07 fedup41

I hit this issue because I wanted to see an application version during startup. I implemented a workaround by putting the application version into application.properties like app-version: @project.version@. It is resolved by Maven. Then you can use it this property in banner.txt or implement a custom startup logger. You can also use BuildProperties bean if you use Actuator where the application version is read from build info.

Saljack avatar Jun 18 '24 11:06 Saljack