我通过spring-cloud Brixton.M2使用Spring Boot 1.3.0.RC1,并且无法将此弹簧启动属性拖入logback.xml,如此功能所示Support springProperty in logback configurationsLogback和Spring Boot的新springProperty查找机制不起作用
我正在使用.yml文件,并希望从bootstrap.yml或application.yml中提取应用程序名称。
的logback-spring.xml:
<configuration>
<springProperty scope="context" name="myappName" source="spring.application.name"/>
<contextName>${myappName}</contextName>
<appender name="logFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/${myappName}.log</file>
...
</appender>
...
</configuration>
文档这里Spring Boot Logback extensions并没有多大帮助。
这个其他stackoverflow的问题Unable to use Spring Property Placeholders in logback.xml比较老,不适合我。任何见解都会有所帮助。
每请求时,这里是正在使用
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.3.0.RC1:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.3.0.RC1:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:1.3.0.RC1:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.3.0.RC1:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.3.0.RC1:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.1.3:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.1.3:compile
[INFO] | | | +- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile
[INFO] | | | +- org.slf4j:jul-to-slf4j:jar:1.7.12:compile
[INFO] | | | \- org.slf4j:log4j-over-slf4j:jar:1.7.12:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.16:runtime
每对信息第二请求相关的依赖关系树,什么是真正回事是的logback财产myappName没有得到一个值。我知道这一点的方式是将值变为“myappName_IS_UNDEFINED”,并将我的日志文件命名为“myappName_IS_UNDEFINED.log”,将%contextName设置为“myappName_IS_UNDEFINED”。
你需要至少包括你的构建控制文件(Maven或Gradle)。 – chrylis