I would like to use the build properties in /META-INF/build-info.properties
as normal Spring properties, so that I am able to use them in via spring-property
in my Logback configuration logback-spring.xml
.
I was already able to use them, but something changed...
/META-INF/build-info.properties
is there.BuildProperties
as bean with the correct values.Does someone knows, how to use the build properties like normal Spring properties in my logback-spring.xml
?
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<springProperty scope="context" name="application" source="build.name"/>
<springProperty scope="context" name="version" source="build.version"/>
In your Spring Boot application, make sure that the build-info.properties file is being loaded as a property source. This can be done by adding the following entry to your application.properties
spring.config.name=application,build-info
spring.config.location=classpath:/,classpath:/META-INF/
Once the build properties are loaded as normal Spring properties, you can use them in your logback-spring.xml configuration file by referencing them using the ${propertyKey} syntax.
like example-:
<configuration>
<property resource="META-INF/build-info.properties" />
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!-- Use the build property in the appender configuration -->
<encoder pattern="${build.version} - %msg%n" />
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
In this example, the ${build.version} property is accessed from the build-info.properties file and used within the configuration.