読者です 読者をやめる 読者になる 読者になる

spring で logback を使う際に application.yml の値を使う

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html#_environment_properties

The <springProperty> tag allows you to surface properties from the Spring Environment for use within Logback. This can be useful if you want to access values from your application.properties file in your logback configuration.

どうやら springProperty を使うと良いらしい。多分こういうこと。

application.yml

my:
  log:
    prop: DEBUG 

logback-spring.xml

...
  <springProperty name="myLogProp" source="my.log.prop" />

  <logger name="com.example.log">
    <appender-ref ref="${myLogProp}" />
  </logger> 
...