我想在项目中正确配置日志记录并删除无所不在的警告
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.
引用的网站段落不包含任何提示要做什么,现有的问题,如Exception thrown while using logback/slf4j,建议做我做的事情。我的mvn dependency:tree
现在是
[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请求来自哪里?
答案 0 :(得分: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应该是您打印日志所需的。但是glassfish jar中的org/slf4j/impl/StaticLoggerBinder.class
也可以实现slf4j logging api。
所以,你应该做的是排除glassfish-embedded-all。如果你真的需要它,你应该包括一些其他版本的glassfish-embedded,而不是-all
jar。或者至少,你可以删除glassfish-embedded-all.jar中的org / slf4j / impl / StaticLoggerBinder.class