the*_*dam 15
您必须使用使用log4j的库.你能发布更多关于你的项目的信息吗?
你应该把log4j桥放在类路径上.在这里阅读更多:http: //www.slf4j.org/legacy.html
你想要研究的jar是log4j-over-slf4j.它将桥接log4j API以实际调用您的slf4j API实现(在您的情况下 - logback).
如果您使用Maven来构建项目,那么它可能就像放置一样简单
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.7</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
在依赖中.
排除库(如果需要)将以这种方式完成(这假设我们正在讨论来自您提到的jar的传递依赖性):
<dependency>
<groupId>org.swift.common</groupId>
<artifactId>jira-soap</artifactId>
<version>4.4.0</version>
<exclusions>
<exclusion>
<groupId>...</groupId>
<artifactId>...</artifactId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)
花了一些时间才发现,因为消息是log4j:WARN没有为记录器找到appender
我试图排除log4j,我尝试了log4j-over-slf4j.
然后我运行了mvn依赖:tree并最终发现mye commons-configuration实际上是在使用commons-logging
[INFO] +- commons-configuration:commons-configuration:jar:1.9:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.0.13:compile
[INFO] | +- ch.qos.logback:logback-core:jar:1.0.13:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] +- org.slf4j:log4j-over-slf4j:jar:1.7.6:compile
[INFO] \- org.apache.commons:commons-lang3:jar:3.1:compile
Run Code Online (Sandbox Code Playgroud)
这成了我的解决方案.
<!-- logging with logback (and slf4j)-->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<!-- had a dep in commons-configuration -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.6</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)