2017-07-05 46 views
0

我有一个sbt/scala项目,其中包括依赖项“ch.qos.logback”%“logback-classic”%“1.0.13”,并包含一个logback.xml文件其内容在这里:logback忽略我的logback.xml

<configuration debug="true"> 
    <logger name="com.typesafe.sslconfig.ssl.ConfigSSLContextBuilder" level="ERROR"/> 
    <logger name="com.typesafe.sslconfig.ssl.AlgorithmChecker" level="ERROR"/> 

    <root level="ERROR"> 
     <appender class="ch.qos.logback.core.ConsoleAppender"> 
      <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
       <pattern>%d{ISO8601} | %-5level | %thread | %logger{1} | %m%n</pattern> 
      </encoder> 
     </appender> 
    </root> 
</configuration> 

https://pastebin.com/S1qauMi9 

当我运行该程序,我在这里得到的输出:

[WARN] [07/05/2017 16:01:25.782] [main] [com.typesafe.sslconfig.ssl.ConfigSSLContextBuilder] validateStore: Skipping certificate with weak key size in thawtepremiumserverca: Certificate failed: cert = "1.2.840.113549.1.9.1=#16197072656d69756d2d736572766572407468617774652e636f6d,CN=Thawte Premium Server CA,OU=Certification Services Division,O=Thawte Consulting cc,L=Cape Town,ST=Western Cape,C=ZA" failed on constraint RSA keySize < 2048, algorithm = RSA, keySize = 1024 
[WARN] [07/05/2017 16:01:25.782] [main] [com.typesafe.sslconfig.ssl.ConfigSSLContextBuilder] validateStore: Skipping certificate with weak key size in thawteserverca: Certificate failed: cert = "1.2.840.113549.1.9.1=#16177365727665722d6365727473407468617774652e636f6d,CN=Thawte Server CA,OU=Certification Services Division,O=Thawte Consulting cc,L=Cape Town,ST=Western Cape,C=ZA" failed on constraint RSA keySize < 2048, algorithm = RSA, keySize = 1024 

...

16:01:25,822 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy] 
16:01:25,822 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 
16:01:25,822 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/Users/eswenson/Projects/Modulus/ws/modulus-shared-libraries/modules/dataset-client-cli/target/scala-2.11/dataset-client-cli-assembly-1.0.dev.jar!/logback.xml] 
16:01:25,833 |-INFO in [email protected] - URL [jar:file:/Users/eswenson/Projects/Modulus/ws/modulus-shared-libraries/modules/dataset-client-cli/target/scala-2.11/dataset-client-cli-assembly-1.0.dev.jar!/logback.xml] is not of type file 
16:01:25,873 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.typesafe.sslconfig.ssl.ConfigSSLContextBuilder] to ERROR 
16:01:25,873 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.typesafe.sslconfig.ssl.AlgorithmChecker] to ERROR 
16:01:25,873 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR 
16:01:25,907 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 
16:01:25,908 |-INFO in [email protected] - Registering current configuration as safe fallback point 
[WARN] [07/05/2017 16:01:26.084] [main] [com.typesafe.sslconfig.ssl.ConfigSSLContextBuilder] validateStore: Skipping certificate with weak key size in thawtepremiumserverca: Certificate failed: cert = "1.2.840.113549.1.9.1=#16197072656d69756d2d736572766572407468617774652e636f6d,CN=Thawte Premium Server CA,OU=Certification Services Division,O=Thawte Consulting cc,L=Cape Town,ST=Western Cape,C=ZA" failed on constraint RSA keySize < 2048, algorithm = RSA, keySize = 1024 
[WARN] [07/05/2017 16:01:26.085] [main] [com.typesafe.sslconfig.ssl.ConfigSSLContextBuilder] validateStore: Skipping certificate with weak key size in thawteserverca: Certificate failed: cert = "1.2.840.113549.1.9.1=#16177365727665722d6365727473407468617774652e636f6d,CN=Thawte Server CA,OU=Certification Services Division,O=Thawte Consulting cc,L=Cape Town,ST=Western Cape,C=ZA" failed on constraint RSA keySize < 2048, algorithm = RSA, keySize = 1024 

Full log here: https://pastebin.com/6Xd10TZZ 

两个问题:

1)为什么有java日志输出BEFORE logback似乎正在配置?我如何确保首次初始化logback?

2)为什么所有来自com.typesafe.sslconfig.ssl.ConfigSSLContextBuilder的警告都会被记录下来,当我明确地将这些警告设置为ERROR时?

我已启用logback配置调试,以便您可以看到logback确实声称将loglevel设置为此类的ERROR。但仍然记录消息。

回答

0

根标签内允许的唯一标签是appender-ref,其中您通过名称[1]引用之前定义的appender。将你的appender定义移动到你的配置的开始处,并且只在根中引用它。另外,如果你对logback配置的理解是基本的,你应该首先通过阅读手册来改变它[2]。

[1] https://logback.qos.ch/manual/configuration.html#rootElement

[2] https://logback.qos.ch/manual/index.html

+0

更改为此,并没有帮助。仍然有完全相同的行为: https://pastebin.com/2nGkB934 – eswenson

+0

任何人有任何建议吗? – eswenson

0

问题竟然是事实(我仍然不明白为什么这是真的),下列阿卡配置逻辑:

akka { 
    loglevel = "ERROR" 
    stdout-loglevel = "ERROR" 
    loggers = ["akka.event.slf4j.Slf4jLogger"] 
} 

它包含在CLI实用程序使用的库中的reference.conf中,需要将其添加到CLI JAR中尚不存在的application.conf中。虽然我不明白为什么这是必要的,但它导致问题消失。我以为在库中包含一个reference.conf,如果没有被库中的调用者的相应配置覆盖,它仍然会生效。显然,我错了。