当前位置: 首页 > 知识库问答 >
问题:

slf4j绑定在哪里?

傅自明
2023-03-14

我想在我的项目中正确配置日志记录,并删除了无处不在的警告

SLF4J: Found binding in [jar:file:/home/richter/.m2/repository/ch/qos/logback/logback-classic/1.1.8/logback-classic-1.1.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/richter/.m2/repository/org/glassfish/extras/glassfish-embedded-all/3.2-b06/glassfish-embedded-all-3.2-b06.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

通过Mavenexclusions排除日志记录实现。现在,我最后

SLF4J: The requested version 1.5.6 by your slf4j binding is not compatible with [1.6, 1.7]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.

引用的网站段落不包含任何要做的提示和存在的问题,比如使用logback/slf4j时抛出的异常,建议做我Afaik做的事情。我的MVN依赖项:树现在是

[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ project1-web ---
[INFO] richtercloud:project1-web:war:1.0-SNAPSHOT
[INFO] +- richtercloud:project1-jar:jar:1.0-SNAPSHOT:compile
[INFO] |  +- org.eclipse.persistence:eclipselink:jar:2.5.2:compile
[INFO] |  |  +- org.eclipse.persistence:javax.persistence:jar:2.1.0:compile
[INFO] |  |  \- org.eclipse.persistence:commonj.sdo:jar:2.1.1:compile
[INFO] |  +- org.eclipse.persistence:org.eclipse.persistence.jpa.modelgen.processor:jar:2.5.2:compile
[INFO] |  |  +- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.5.2:compile
[INFO] |  |  |  \- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.5.2:compile
[INFO] |  |  \- org.eclipse.persistence:org.eclipse.persistence.jpa:jar:2.5.2:compile
[INFO] |  |     +- org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.5.2:compile
[INFO] |  |     \- org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:jar:2.5.2:compile
[INFO] |  +- commons-validator:commons-validator:jar:1.4.0:compile
[INFO] |  |  +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] |  |  \- commons-digester:commons-digester:jar:1.8:compile
[INFO] |  +- org.jscience:jscience:jar:4.3.1:compile
[INFO] |  |  \- org.javolution:javolution:jar:5.2.3:compile
[INFO] |  +- org.apache.solr:solr-solrj:jar:6.5.0:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.4.1:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.1:compile
[INFO] |  |  +- org.apache.httpcomponents:httpmime:jar:4.4.1:compile
[INFO] |  |  +- org.apache.zookeeper:zookeeper:jar:3.4.6:compile
[INFO] |  |  +- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] |  |  +- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:compile
[INFO] |  |  \- org.noggit:noggit:jar:0.6:compile
[INFO] |  +- javax:javaee-api:jar:7.0:compile
[INFO] |  |  \- com.sun.mail:javax.mail:jar:1.5.0:compile
[INFO] |  |     \- javax.activation:activation:jar:1.1:compile
[INFO] |  +- richtercloud:message-handler:jar:1.0-SNAPSHOT:compile
[INFO] |  |  +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] |  |  \- com.getsentry.raven:raven:jar:7.8.1:compile
[INFO] |  |     \- com.fasterxml.jackson.core:jackson-core:jar:2.7.3:compile
[INFO] |  \- richtercloud:message-handler-raven-bug-handler:jar:1.0-SNAPSHOT:compile
[INFO] +- org.primefaces:primefaces:jar:6.1:compile
[INFO] +- net.glxn:qrgen:jar:1.4:compile
[INFO] |  \- com.google.zxing:javase:jar:3.0.0:compile
[INFO] |     \- com.google.zxing:core:jar:3.0.0:compile
[INFO] +- net.sf.barcode4j:barcode4j-light:jar:2.1:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- richtercloud:validation-tools:jar:1.0-SNAPSHOT:compile
[INFO] +- org.httpunit:httpunit:jar:1.7.2:test
[INFO] |  +- rhino:js:jar:1.6R5:test
[INFO] |  +- nekohtml:nekohtml:jar:0.9.5:test
[INFO] |  +- javax.servlet:servlet-api:jar:2.4:test
[INFO] |  +- net.sf.jtidy:jtidy:jar:r938:test
[INFO] |  \- xerces:xmlParserAPIs:jar:2.6.1:test
[INFO] +- commons-io:commons-io:jar:2.5:compile
[INFO] +- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-javaee:jar:2.0.0-alpha-10:test
[INFO] |  \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-base:jar:2.0.0-alpha-10:compile
[INFO] +- org.jboss.jsfunit:jsfunit-arquillian:jar:2.0.0.Beta3-SNAPSHOT:test
[INFO] |  +- org.jboss.jsfunit:jboss-jsfunit-core:jar:2.0.0.Beta3-SNAPSHOT:test
[INFO] |  |  +- net.sourceforge.htmlunit:htmlunit:jar:2.8:test
[INFO] |  |  |  \- commons-codec:commons-codec:jar:1.4:test
[INFO] |  |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.8:test
[INFO] |  |  +- org.apache.james:apache-mime4j:jar:0.6:test
[INFO] |  |  +- commons-lang:commons-lang:jar:2.4:test
[INFO] |  |  +- commons-collections:commons-collections:jar:3.2.1:test
[INFO] |  |  +- net.sourceforge.cssparser:cssparser:jar:0.9.5:test
[INFO] |  |  |  \- org.w3c.css:sac:jar:1.3:test
[INFO] |  |  +- net.sourceforge.nekohtml:nekohtml:jar:1.9.14:test
[INFO] |  |  \- xalan:xalan:jar:2.7.1:test
[INFO] |  |     \- xalan:serializer:jar:2.7.1:test
[INFO] |  +- org.jboss.shrinkwrap:shrinkwrap-api:jar:1.2.6:test
[INFO] |  \- org.jboss.arquillian.protocol:arquillian-protocol-servlet:jar:1.1.13.Final:test
[INFO] |     \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-spi:jar:2.0.0-alpha-10:compile
[INFO] +- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-impl-javaee:jar:2.0.0-alpha-10:compile
[INFO] |  \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-impl-base:jar:2.0.0-alpha-10:compile
[INFO] +- xerces:xercesImpl:jar:2.11.0:test
[INFO] |  \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- javax:javaee-web-api:jar:7.0:provided
[INFO] +- org.powermock:powermock-module-junit4:jar:1.7.0RC4:test
[INFO] |  \- org.powermock:powermock-module-junit4-common:jar:1.7.0RC4:test
[INFO] |     +- org.powermock:powermock-reflect:jar:1.7.0RC4:test
[INFO] |     \- org.powermock:powermock-core:jar:1.7.0RC4:test
[INFO] |        \- org.javassist:javassist:jar:3.21.0-GA:test
[INFO] +- org.powermock:powermock-api-mockito2:jar:1.7.0RC4:test
[INFO] |  +- org.powermock:powermock-api-mockito-common:jar:1.7.0RC4:test
[INFO] |  |  \- org.powermock:powermock-api-support:jar:1.7.0RC4:test
[INFO] |  \- org.mockito:mockito-core:jar:2.7.5:test
[INFO] |     +- net.bytebuddy:byte-buddy:jar:1.6.5:test
[INFO] |     +- net.bytebuddy:byte-buddy-agent:jar:1.6.5:test
[INFO] |     \- org.objenesis:objenesis:jar:2.5:test
[INFO] +- net.sf.jmimemagic:jmimemagic:jar:0.1.3:compile
[INFO] |  +- oro:oro:jar:2.0.8:compile
[INFO] |  +- xml-apis:xmlParserAPIs:jar:2.0.2:compile
[INFO] |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.5.2:compile
[INFO] |  |  +- org.codehaus.jackson:jackson-core-asl:jar:1.5.2:compile
[INFO] |  |  \- org.codehaus.jackson:jackson-mapper-asl:jar:1.5.2:compile
[INFO] |  \- org.codehaus.jackson:jackson-xc:jar:1.5.2:compile
[INFO] +- org.imgscalr:imgscalr-lib:jar:4.3-SNAPSHOT:compile
[INFO] +- org.ocpsoft.prettytime:prettytime:jar:3.2.7.Final:compile
[INFO] +- org.bitbucket.cowwoc:diff-match-patch:jar:1.1:compile
[INFO] +- org.rauschig:jarchivelib:jar:0.7.1:compile
[INFO] |  \- org.apache.commons:commons-compress:jar:1.9:compile
[INFO] +- org.jboss.arquillian.junit:arquillian-junit-container:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.junit:arquillian-junit-core:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.test:arquillian-test-api:jar:1.1.13.Final:test
[INFO] |  |  \- org.jboss.arquillian.core:arquillian-core-api:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.test:arquillian-test-spi:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-test-api:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-test-spi:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.core:arquillian-core-impl-base:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.test:arquillian-test-impl-base:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-impl-base:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-test-impl-base:jar:1.1.13.Final:test
[INFO] |  \- org.jboss.shrinkwrap:shrinkwrap-impl-base:jar:1.2.6:test
[INFO] |     \- org.jboss.shrinkwrap:shrinkwrap-spi:jar:1.2.6:test
[INFO] +- org.jboss.arquillian.container:arquillian-container-spi:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.core:arquillian-core-spi:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.config:arquillian-config-api:jar:1.1.13.Final:test
[INFO] |  \- org.jboss.arquillian.config:arquillian-config-impl-base:jar:1.1.13.Final:test
[INFO] +- org.jboss.arquillian.container:arquillian-glassfish-embedded-3.1:jar:1.0.0.Final:test
[INFO] |  +- org.jboss.arquillian.testenricher:arquillian-testenricher-cdi:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.testenricher:arquillian-testenricher-ejb:jar:1.1.13.Final:test
[INFO] |  +- org.jboss.arquillian.testenricher:arquillian-testenricher-resource:jar:1.1.13.Final:test
[INFO] |  \- org.jboss.arquillian.testenricher:arquillian-testenricher-initialcontext:jar:1.1.13.Final:test
[INFO] +- org.glassfish.extras:glassfish-embedded-all:jar:3.2-b06:test
[INFO] \- org.ow2.asm:asm-commons:jar:5.0.3:runtime
[INFO]    \- org.ow2.asm:asm-tree:jar:5.0.3:runtime
[INFO]       \- org.ow2.asm:asm:jar:5.0.3:runtime

我需要slf4j-api以便能够编译项目。旧的API请求从何而来?

共有1个答案

田骁
2023-03-14
SLF4J: Found binding in [jar:file:/home/richter/.m2/repository/ch/qos/logback/logback-classic/1.1.8/logback-classic-1.1.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/richter/.m2/repository/org/glassfish/extras/glassfish-embedded-all/3.2-b06/glassfish-embedded-all-3.2-b06.jar!/org/slf4j/impl/StaticLoggerBinder.class]

它说得很清楚,您在glassfish-embedded-all-3.2-b06.jar和logback-classic-1.1.8.jar中都有slf4j绑定。

Logback应该是打印日志所真正需要的内容。但glassfish jar中的org/slf4j/impl/staticloggerbinder.class也可以实现slf4j日志API。

因此,您应该做的是排除GlassFish-Embedded-All。如果您真的需要它,您应该包含一些其他版本的GlassFish嵌入式,而不是-alljar。或者至少可以在glassfish-embedded-all.jar中删除org/slf4j/impl/staticloggerbinder.class

 类似资料:
  • 问题内容: 我正在使用slf4j登录我的应用程序。我得到slf4j的目的。我想知道如何找出当前绑定到哪个日志记录库slf4j。我的引用库中有log4j。我假设slf4j已将自身绑定到log4j。 我想知道的是,有什么方法可以明确确认这种绑定吗? 问题答案: 只需执行SLF4J的操作来发现绑定: 现在,你可以尝试找出什么是实际执行的logback在我的情况: 打印:

  • 问题内容: 我正在尝试使用maven2托管的依存关系设置一个Webapp。这是我的pom.xml 如果我遇到问题,请纠正我,但是应该可以吗?我只在日食中遇到这个例外 我的设置有什么问题? 问题答案: 在依赖项中包含slf4j-api: 为您声明的spring依赖关系中的至少一个排除commons-logging依赖关系,并为commons-logging提供slf4j门面: 将用于日志记录的log

  • 我得到以下错误。似乎有多个日志记录框架绑定到SLF4J。不知道该怎么解决。非常感谢任何帮助。

  • 这可能是一个重复的问题,但我无法弄清楚绑定冲突在哪里。我有我的服务,当我运行它时,我得到了这个错误: 这是输出 显然,问题在于<code>logback</code>仍然在类路径中,但我在输出中找不到它,所以我不知道问题出在哪里。 你能发现错误吗?我将感谢你的帮助 这仅在我将服务器作为Spring Boot Application运行时发生。如果我将其作为java应用程序运行,错误就消失了....

  • 我正在尝试运行gradle从IntelliJ IDEA生成的战争。 tomcat实例运行时的输出: