0

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

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]

通过 Maven 排除日志记录实现exclusions。现在,我结束了

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 时抛出的异常)建议做我所做的事情。我mvn dependency:tree的现在

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

我需要slf4j-api为了能够编译项目。旧的 API 请求来自哪里?

4

1 回答 1

0
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 bingding。

Logback 应该是您真正需要打印日志的内容。但是org/slf4j/impl/StaticLoggerBinder.class在 glassfish jar 中也可以实现 slf4j logging api。

所以,你应该做的是排除 glassfish-embedded-all。如果你真的需要它,你应该包括一些其他版本的 glassfish-embedded,而不是-alljar。或者至少,您可以删除 glassfish-embedded-all.jar 中的 org/slf4j/impl/StaticLoggerBinder.class

于 2017-07-18T10:53:56.123 回答