Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring boot : application name / version not shown at log startup. #42324

Closed
alexisgayte opened this issue Sep 16, 2024 · 4 comments
Closed

Spring boot : application name / version not shown at log startup. #42324

alexisgayte opened this issue Sep 16, 2024 · 4 comments
Labels
status: superseded An issue that has been superseded by another

Comments

@alexisgayte
Copy link

alexisgayte commented Sep 16, 2024

While the documentation give the way to create a file properties with all informations (build.info).
https://docs.spring.io/spring-boot/how-to/build.html#howto.build.generate-info

The code doesn't take into consideration those informations.

private void appendApplicationName(StringBuilder message) {
append(message, "",
() -> (this.sourceClass != null) ? ClassUtils.getShortName(this.sourceClass) : "application");
}
private void appendVersion(StringBuilder message, Class<?> source) {
append(message, "v", () -> source.getPackage().getImplementationVersion());
}
private void appendApplicationVersion(StringBuilder message) {
append(message, "v", () -> this.environment.getProperty("spring.application.version"));
}

The code seems to have changed tho I am using springboot 3.3.3.
However, it seems that build.info properties are completely ignored even now.

#41604

Regarding the application name there is also a properties : spring.application.name
wondering if that properties is not better than the class name to determine the application name.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 16, 2024
@wilkinsona
Copy link
Member

wilkinsona commented Sep 16, 2024

Sorry, I don't think I understand the problem that you're reporting. The BuildProperties bean that is auto-configured from a build-info.properties file is, and always has been, separate from the information that's logged when the application starts up. BuildProperties cannot be used, even if we wanted to do so, as beans are not available at this early point in the application's startup.

Can you please clarify what you expected to happen and why you had those expectations, for example linking to documentation that says that the contents of the build-info.properties would be used by the startup info logging?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Sep 16, 2024
@alexisgayte
Copy link
Author

alexisgayte commented Sep 16, 2024

BuildProperties cannot be used, even if we wanted to do so, as beans are not available at this early point in the application's startup.

gotcha, make sense.

Can you please clarify what you expected to happen and what you had those expectations, for example linking to documentation that says that the contents of the build-info.properties would be used by the startup info logging?

To be honest I was just expecting to have the info from build-info printed somewhere.
somewhere in the log I was looking for : build name / build version / etc . It would have make sense to have it at startup.

Using the class name seems strange if you have spring.application.name as properties.
And not having the spring.application.name printed is strange as well.
For example my log line looks like : "Starting Application using Java xxx" with class name Application.class (pretty useless)

I was expecting to have build.info that is explicitly generated to get this information to be used by default if no version or no name was present.
Or to be able to set spring.application.version = ${build.version} or spring.application.version = ${build.version} (${build.commit})

After another look at it the documentation doesn't say anything about using build-info information. And may be, it doesn't make sense to use them as build can be different than application. Yet from actuator perspective that is the only information that are shown by default (I would assume application and version should be there as default). build version / build name.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 16, 2024
@philwebb
Copy link
Member

I've opened #42324 to consider logging a bit more. In the meantime, you can use a custom banner.txt if you want and where you should be able to use ${<variable>} to access any property in the Spring Environment.

@philwebb philwebb closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2024
@philwebb philwebb added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Sep 16, 2024
@alexisgayte
Copy link
Author

alexisgayte commented Sep 17, 2024

Thanks, banner.txt is a bit overkilled for my need, also as you said BuildProperties is not loaded at that time. I've just created a log line from a bean creation with BuildProperties.

After more thought about it, I think this log is fine as it show low level information from the startup of what is running etc.
I think I was confused probably due to previous spring version and the banner that show Spring boot version(3.3.3) which is an higher level. I was somehow expected the application name + version after.

Here is the start up :

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.3.3)

11:22:11.878 [main] INFO  xxx.Application - Starting Application using Java 17.x.x with PID 76xx (/xx/xxx/xxx/xx/main started by xxxx in /xxx/xxx)
11:22:11.884 [main] INFO  xxx.Application - The following 1 profile is active: "xxx"

Perhaps the "appendApplicationName"[Application] should not be stripped of .class and all higher level information should be printed with the profile line. like version.
You can also keep the wording consistent with the code (Running vs Starting) SpringApplication.run(Application.class, args);
Like :

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.3.3)

11:22:11.878 [main] INFO  xxx.Application - Running Application.class using Java 17.x.x with PID 76xx (/xx/xxx/xxx/xx/main started by xxxx in /xxx/xxx)
11:22:11.884 [main] INFO  xxx.Application - Starting "Application name" "version" ("commit") with the following 1 profile is active: "xxx"

Just an idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

No branches or pull requests

4 participants