相关疑难解决方法(0)

Websphere多个slf4j logback绑定可以解决

我在Websphere v8.5.5.0上运行一个应用程序,并尝试使用logback作为我的日志框架.

当我尝试启动应用程序时,我遇到类似于错误的问题:

[10/03/14 13:19:00:900 EST] 00000097 SystemErr     R   SLF4J: Class path contains multiple SLF4J bindings.
[10/03/14 13:19:00:900 EST] 00000097 SystemErr     R   SLF4J: Found binding in [bundleresource://266.fwk1755217229:1/org/slf4j/impl/StaticLoggerBinder.class]
[10/03/14 13:19:00:900 EST] 00000097 SystemErr     R   SLF4J: Found binding in    [wsjar:file:/C:/Program%20Files%20(x86)/IBM/WebSphere/AppServer_1/profiles/AppSrv01/installedApps/AUSSYDCVTLJ007Node02Cell/myapp.ear/lib/logback-classic-1.1.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
[10/03/14 13:19:00:900 EST] 00000097 SystemErr     R   SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
[10/03/14 13:19:01:313 EST] 00000097 SystemErr     R   SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Run Code Online (Sandbox Code Playgroud)

正如答案所解释的那样,ibm库已经包含了类路径上的logback-classic库的实现.我想了解最新的logback,所以想知道是否有人可以告诉我如何手动选择要使用的绑定(不使用父级最后一个类加载器!).

java websphere logback slf4j

5
推荐指数
2
解决办法
1万
查看次数

使用dropwizard的阴影jar我得到:类路径包含多个SLF4J绑定

我可能在这里做了些蠢事.我的dropwizard设置有一些(小的)错误.运行着色jar工作正常,但在执行集成测试时,我收到此警告:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/graphhopper/web/target/graphhopper-web-0.11-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/user/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.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]
INFO  [2018-04-08 18:44:27,653] org.eclipse.jetty.util.log: Logging initialized @1090ms to org.eclipse.jetty.util.log.Slf4jLog
Run Code Online (Sandbox Code Playgroud)

graphhopper-web-0.11-SNAPSHOT.jar是带有dropwizard(带有logback)的阴影jar.

通常意味着类路径上不止一个slf4j绑定,但我可以拒绝这个理论,只有slf4j-api存在,加上dropwizard的logback依赖.我还用Netbeans和.分析了依赖图

mvn dependency:tree -Dverbose -Dincludes=org.slf4j

(见这里的输出)但找不到有问题的东西.

是否可以将阴影jar(带有logback)以某种方式与其他jar(包括logb​​ack)一起放入classpath中mvn clean install?我怎么能避免这个?

通过以下方式重现:

git clone https://github.com/graphhopper/graphhopper
cd web
mvn clean install
Run Code Online (Sandbox Code Playgroud)

看到这个问题.

logback slf4j dropwizard

5
推荐指数
1
解决办法
546
查看次数

标签 统计

logback ×2

slf4j ×2

dropwizard ×1

java ×1

websphere ×1