Hi I want to use a DBAppenderin my Spring Boot application. I want to retrieve database connection properties from the application.properties file.
Stumbled upon this while searching for a similar solution. Since this is still unanswered, here's a few approaches I found:
1) If you are using Spring Boot 1.3+ (which you already pointed out you're not but for future reference), I managed to use the
application.properties (for embedded H2 DB):
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=
logback-spring.xml:
${spring.datasource.driverClassName}
${spring.datasource.url}
${spring.datasource.username}
${spring.datasource.password}
2) Import application properties as property source: Unable to use Spring Property Placeholders in logback.xml
3) Maybe you're able to register the Datasource in the container JNDI and use logback's JNDIConnectionSource instead? Check out this other post: How to create JNDI context in Spring Boot with Embedded Tomcat Container