logging - 排除 ch.qos.logback 溢出

标签 logging gradle build.gradle slf4j

我正在使用:

compile (libs.spring_boot_starter_logging)
testCompile 'org.apache.qpid:qpid-broker:0.28'

他们都有一个 SLF4J 绑定(bind),所以我有错误:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/maciej.glowala.ext/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.1.11/ccedfbacef4a6515d2983e3f89ed753d5d4fb665/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/maciej.glowala.ext/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.6.4/6b4973e0320e220ec6534478d60233fd1cc51c9b/slf4j-log4j12-1.6.4.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]

我可以从 qpid-broker 中排除版本 1.6.4 但它会出错,因为代理找不到包含在较新版本中的某些方法。当我想排除版本 1.1.11
compile (libs.spring_boot_starter_logging){
            exclude group: 'ch.qos.logback', module: 'logback-classic'
        }

我有一个溢出错误
java.lang.StackOverflowError
    at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:39)
    at org.apache.log4j.LogManager.getLogger(LogManager.java:45)
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
    at org.apache.log4j.Category.<init>(Category.java:57)
    at org.apache.log4j.Logger.<init>(Logger.java:37)
    at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:43)
    at org.apache.log4j.LogManager.getLogger(LogManager.java:45)
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
    at org.apache.log4j.Category.<init>(Category.java:57)
    at org.apache.log4j.Logger.<init>(Logger.java:37)
    .
    .
    .

更重要的是,我不应该从 compile 中排除。当SLF4J绑定(bind)包含在 testCompile 中所以我想排除测试只使用
configurations {
    testCompile.exclude group:'ch.qos.logback'
}

但无论如何我仍然有同样的溢出错误。任何人都可以帮助我如何设置 build.gradle 以使用更新版本进行测试?

最佳答案

如果将来有人需要它,请通过附加排除解决它:

testCompile.exclude group:'org.slf4j', module:'log4j-over-slf4j'

关于logging - 排除 ch.qos.logback 溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46158724/

相关文章:

java - 在 Gradle 中禁用所有 JavaDoc

c# - 有没有办法忽略 ASP.NET Core 中 HTTP 日志记录中的 swagger 响应?

java - 使用 Gradle 生成 Querydsl 类的问题

java - Log4j2 - 找到配置,但无法正常工作

java - Spring boot Gradle 不生成包装器并且不生成可运行的 jar

java - 成功后,步骤无法在 travis-ci 构建中的项目根目录下找到文件

java - 在gradle中的jar命令中使用include和exclude并没有包含所有需要的类

android - 在 Android Studio 中更新外部库

python - 如何将ApScheduler日志写入文件?

java - Log4j 用法 - 登录 Windows 事件日志时如何自定义事件 ID?