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

Add spring.application.name to StartupInfoLogger #42390

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nosan
Copy link
Contributor

@nosan nosan commented Sep 19, 2024

Starting StartupInfoLoggerTests "spring-boot" v1.2.3 using Java 17.0.12 (started by dmytronosan in /Users/dmytronosan/IdeaProjects/spring-boot/spring-boot-project/spring-boot)

Starting AOT-processed StartupInfoLoggerTests "spring-boot" v1.2.3 using Java 17.0.12 with PID 42 (started by dmytronosan in /Users/dmytronosan/IdeaProjects/spring-boot/spring-boot-project/spring-boot)

Starting StartupInfoLoggerTests "spring-boot" v1.2.3 using Java 17.0.12 with PID 42 (started by dmytronosan in /Users/dmytronosan/IdeaProjects/spring-boot/spring-boot-project/spring-boot)

Restored StartupInfoLoggerTests "spring-boot" in 0.0 seconds

Started StartupInfoLoggerTests "spring-boot" in 0.0 seconds (process running for 1.345)

spring.application.name is not present

Starting StartupInfoLoggerTests v1.2.3 using Java 17.0.12 with PID 42 (started by dmytronosan in /Users/dmytronosan/IdeaProjects/spring-boot/spring-boot-project/spring-boot)

gh-42330

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 19, 2024
@nosan
Copy link
Contributor Author

nosan commented Sep 19, 2024

git.commit.id if needed could be fetched by:

private void appendGitCommit(StringBuilder message) {
	append(message, "", () -> {
		String location = this.environment.getProperty("spring.info.git.location", "classpath:git.properties");
		String encoding = this.environment.getProperty("spring.info.git.encoding", "UTF-8");
		Resource resource = this.resourceLoader.getResource(location);
		Properties properties = loadSource(resource, encoding);
		return properties.getProperty("git.commit.id");
	});
}

private Properties loadSource(Resource location, String encoding) throws IOException {
	if (encoding != null) {
		return PropertiesLoaderUtils.loadProperties(new EncodedResource(location, encoding));
	}
	return PropertiesLoaderUtils.loadProperties(location);
}

@nosan nosan changed the title Added spring.application.name to StartupInfoLogger Add spring.application.name to StartupInfoLogger Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants