Spring Boot - logging.file属性没有任何影响?

时间:2014-02-02 10:10:53

标签: spring-boot

我使用Boot 1.0.0.RC1编写了一个应用程序

默认日志记录配置输出可以满足我的需求,并且根据http://projects.spring.io/spring-boot/docs/spring-boot/README.html我应该能够在application.properties中设置logging.file属性,以指定日志文件将存储在磁盘上的位置。

但这似乎没有任何效果。我的日志最终在/tmp/spring.log

logging.file属性在application.properties中定义:

logging.file=/tmp/mylog.log

mvn依赖的输出:tree:

[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.0.0.RC1:compile
[INFO] |  \- org.springframework.boot:spring-boot-actuator:jar:1.0.0.RC1:compile
[INFO] |     \- org.hsqldb:hsqldb:jar:2.3.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.0.0.RC1:compile
[INFO] |  +- org.springframework.boot:spring-boot:jar:1.0.0.RC1:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.0.0.RC1:compile
[INFO] |  \- org.springframework.boot:spring-boot-starter-logging:jar:1.0.0.RC1:compile
[INFO] |     +- org.slf4j:jcl-over-slf4j:jar:1.7.5:compile
[INFO] |     +- org.slf4j:jul-to-slf4j:jar:1.7.5:compile
[INFO] |     +- org.slf4j:log4j-over-slf4j:jar:1.7.5:compile
[INFO] |     \- ch.qos.logback:logback-classic:jar:1.0.13:compile
[INFO] |        \- ch.qos.logback:logback-core:jar:1.0.13:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:1.0.0.RC1:compile
[INFO] |  +- org.springframework.security:spring-security-config:jar:3.2.0.RELEASE:compile
[INFO] |  |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  |  \- org.springframework.security:spring-security-core:jar:3.2.0.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-web:jar:3.2.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:4.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:4.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-expression:jar:4.0.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-web:jar:4.0.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.0.0.RC1:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.0.0.RC1:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:7.0.47:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:7.0.47:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.1:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.3.1:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:4.0.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.0.0.RC1:compile
[INFO] |  +- org.springframework:spring-jdbc:jar:4.0.0.RELEASE:compile
[INFO] |  +- org.apache.tomcat:tomcat-jdbc:jar:7.0.47:compile
[INFO] |  |  \- org.apache.tomcat:tomcat-juli:jar:7.0.47:compile
[INFO] |  \- org.springframework:spring-tx:jar:4.0.0.RELEASE:compile
[INFO] +- org.thymeleaf:thymeleaf-spring4:jar:2.1.2.RELEASE:compile
[INFO] |  +- org.thymeleaf:thymeleaf:jar:2.1.2.RELEASE:compile
[INFO] |  |  +- ognl:ognl:jar:3.0.6:compile
[INFO] |  |  \- org.javassist:javassist:jar:3.16.1-GA:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.2.1:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.27:compile
[INFO] +- com.h2database:h2:jar:1.3.175:compile
[INFO] +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.0.1.Final:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.1.1.GA:compile
[INFO] |  \- com.fasterxml:classmate:jar:0.8.0:compile
[INFO] +- org.yaml:snakeyaml:jar:1.13:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.0.0.RC1:test
[INFO] |  \- org.springframework:spring-test:jar:4.0.0.RELEASE:test
[INFO] +- junit:junit:jar:4.11:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.mockito:mockito-core:jar:1.9.5:test
[INFO] |  \- org.objenesis:objenesis:jar:1.0:test
[INFO] \- org.hamcrest:hamcrest-library:jar:1.3:test

因此,logback位于类路径上,并从spring-boot中获取默认的base.xml配置。

当时,logging.file属性不应该开箱即用,或者我是否需要以不同方式配置它?

我知道我可以将logback.xml放在classpath中直接以这种方式配置logback,并且可能包含来自base.xml的默认springboot logback配置,但是如果我可以实现相同的简单设置logging.file属性我宁愿这样做。

我使用的方法是在使用java -jar运行嵌入式Tomcat时指定-DLOG_FILE = logs / output.log。

但是我需要构建一个war并在独立的Tomcat中部署它,我无权重新配置和设置环境属性,如LOG_FILE属性 - 所以我需要能够使用我的application.properties指定日志输出

1 个答案:

答案 0 :(得分:1)

我更新了我的pom.xml以使用Springboot的1.0.0.BUILD-SNAPSHOT版本,现在它可以很好地指定application.properties中的logging.file。

这里的任何人都可以告诉我什么时候(大约)春季启动1.0.0.RELEASE计划用于什么时候?

干杯 弗莱明