记录框架不兼容 [英] Logging framework incompatibility
问题描述
我正在构建一个小型Java应用程序并希望使用logback进行日志记录。
I'm building a small Java app and hoping to use logback for logging.
我的应用程序依赖于通过
My app has a dependency on an older project that does its logging via
org.apache.commons | com.springsource.org.apache.commons.logging | 1.1.1
...所以我的计划是使用
...so my plan was to use
org.slf4j | jcl-over-slf4j | 1.5.6
...将JCL日志记录重定向到
...to redirect the JCL logging to
org.slf4j | slf4j-api | 1.6.0
...最终到
ch.qos.logback | logback-classic | 0.9.22
ch.qos.logback | logback-core | 0.9.22
所以我的应用程序可以通过其slf4j API登录回溯,而旧的库代码可以记录通过重定向进入同一位置。
so my app can log through logback via its slf4j API while the old library code can log into the same location via the redirection.
唉,这导致
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:141)
我'我们在其中一些罐子上尝试过更高和更低的验证数字,并且还通过API文档等进行挖掘...但我无法找到并解决问题。
I've tried higher and lower verision numbers on some of these jars and also digging through API documentation and such... but I'm unable to find and solve the problem.
请帮助?
虽然logback被认为是战略日志框架,但我有一些余地我最终使用哪种日志记录机制。我希望使用logback或log4j,我肯定希望通过常见配置将旧项目的日志记录合并到新日志框架最终的任何内容中。
Although logback is considered the "strategic" logging framework, I have some leeway in which logging mechanism I ultimately use. I'd hope to use either logback or log4j, though, and I definitely want to merge the old project's logging into whatever the "new" logging framework ends up being, via a common configuration.
推荐答案
您正在将jcl网桥的1.5.6版本与slf4j-api的1.6.0版本混合使用;由于1.6.0中的一些变化,这将无法工作。两者使用相同的版本,即1.6.1(最新版本)。我一直使用jcl-over-slf4j桥,它工作正常。
You are mixing the 1.5.6 version of the jcl bridge with the 1.6.0 version of the slf4j-api; this won't work because of a few changes in 1.6.0. Use the same versions for both, i.e. 1.6.1 (the latest). I use the jcl-over-slf4j bridge all the time and it works fine.
这篇关于记录框架不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!