具有自定义logback配置的Spring启动

时间:2014-08-22 12:33:52

标签: java spring logback spring-boot

我正在尝试为默认的logback配置提供一些自定义日志记录级别,但似乎我的配置文件被忽略了。我虽然Boot可能因为某种原因跳过它,但是如果我使文件无效(例如删除自我关闭标签的/)我得到一个关于无法解析它的例外 - 所以它被拾取

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <!-- Spring boot base -->
    <include resource="org/springframework/boot/logging/logback/base.xml" />

    <logger name="com.wedgetail" level="WARN" />
    <logger name="nv" level="WARN" />
    <logger name="StatsLogger" level="WARN" />

</configuration>

因此,出于测试目的(因为我的记录器可能是错误的拼写或其他),我包括:

<logger name="org.springframework" level="ERROR" />

当应用程序出现时,我仍然看到信息级别的春季登录:

2014-08-22 14:28:34.756  WARN 5444 --- [on(3)-127.0.0.1] o.s.b.l.LoggingApplicationListener       : Logging environment value '-Djava.util.logging.config.file="C:\Documents and Settings\zykajan\.IntelliJIdea13\system\tomcat\Unnamed_cnc-parent_2\conf\logging.properties"' cannot be opened and will be ignored

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.1.5.RELEASE)

2014-08-22 14:28:34.881  INFO 5444 --- [on(3)-127.0.0.1] o.s.boot.SpringApplication               : Starting application on prgdwm395059 with PID 5444 (C:\workspace\command-and-control\webapp\target\cnc-webapp-UNVERSIONED-SNAPSHOT\WEB-INF\lib\spring-boot-1.1.5.RELEASE.jar started by zykajan in C:\Apps\Apache\jakarta\apache-tomcat-7.0.55\bin)
2014-08-22 14:28:34.928  INFO 5444 --- [on(3)-127.0.0.1] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5dd439: startup date [Fri Aug 22 14:28:34 CEST 2014]; root of context hierarchy

我想知道第一行是不是应该响铃而不是我的情况:)

2014-08-22 14:28:34.756  WARN 5444 --- [on(3)-127.0.0.1] o.s.b.l.LoggingApplicationListener       : Logging environment value '-Djava.util.logging.config.file="C:\Documents and Settings\zykajan\.IntelliJIdea13\system\tomcat\Unnamed_cnc-parent_2\conf\logging.properties"' cannot be opened and will be ignored

像往常一样,任何提示都非常赞赏。

1 个答案:

答案 0 :(得分:2)

升级到Spring Boot 1.1.6。修复此issue