【问题标题】:How to get rid of SLF4J bindings in springboot project如何摆脱 Spring Boot 项目中的 SLF4J 绑定
【发布时间】:2021-02-10 03:50:52
【问题描述】:

在其他答案之后,我确实排除了这个,但我开始收到 ERROR An exception occurred processing Appender http java.lang.IllegalArgumentException:

        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
         </exclusions>
         </dependency>

我需要修复 SLF4J 绑定,因为它会阻止我的日志转到 Splunk:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/app.jar!/BOOT-INF/lib/logback-classic- 
      1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/app.jar!/BOOT-INF/lib/log4j-slf4j-impl- 
      2.11.2.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]

【问题讨论】:

    标签: java logging log4j slf4j splunk


    【解决方案1】:

    用 maven 命令检查你的依赖树:

    mvn dependency:tree
    

    您将在那里找到提供现有 SL4J 绑定的依赖项。然后只需将排除项更改为这个。

    更多信息在这里:Spring Boot: multiple SLF4J bindings

    【讨论】:

      猜你喜欢
      • 2016-01-09
      • 1970-01-01
      • 2013-01-28
      • 2019-04-30
      • 2020-11-03
      • 2020-09-25
      • 1970-01-01
      • 2023-02-22
      • 2014-06-20
      相关资源
      最近更新 更多