【问题标题】:slf4j warning about the same binding being duplicateslf4j 关于相同绑定重复的警告
【发布时间】:2011-06-20 22:08:25
【问题描述】:

SLF4J 抱怨有多个绑定,但它们看起来完全一样:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [zip:C:/bea_domains/my_service_domain/servers/AdminServer/tmp/_WL_user/my-shared-app-lib/obaz3z/APP-INF/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [zip:C:/bea_domains/my_service_domain/servers/AdminServer/tmp/_WL_user/my-shared-app-lib/obaz3z/APP-INF/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

有什么办法可以消除这个警告吗?可能是什么原因?

【问题讨论】:

    标签: java logging weblogic slf4j


    【解决方案1】:

    目前正在讨论bug 138,在我看来这与您报告的问题相同。根据讨论,“问题实际上是在清单中的多个类路径中 - 如果有多个 EJB jar 与绑定列出 WLS 提供了这些的完整列表。即使类是相同的。这与 ClassLoader WLS 中的行为。”。如果你想真正删除这个警告(虽然不是致命的),bug中有一个附件,你可以用它来修补slf4j。

    【讨论】:

      【解决方案2】:

      现在 slf4j 1.6.2 中修复了错误 138 :-)。 http://www.slf4j.org/news.html

      【讨论】:

        【解决方案3】:

        除了Jasonw的回答中描述的多个类路径的问题外,这个问题也可能是由模拟框架PowerMock引起的。

        PowerMock 使用自己的类加载器 (MockClassLoader),它使用自己的机制委托给父类加载器。这也可能导致ClassLoader.getResources() 两次返回相同的资源,从而触发警告。

        这似乎是由PowerMock issue 380 中描述的更改引起的。

        对 SLF4J 中 #138 的修复(上面链接)也解决了这个问题,所以在 SLF4J 1.6.2+ 中它应该不再发生。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-11-26
          • 2021-05-19
          • 1970-01-01
          • 1970-01-01
          • 2019-12-07
          • 2018-06-29
          • 2013-01-28
          • 2018-04-20
          相关资源
          最近更新 更多