跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 在 Springmvc 开发中 slf4j-api 1.8+ 和 log4j2 2.14 版本如何绑定
未分類
7 12 月 2020

在 Springmvc 开发中 slf4j-api 1.8+ 和 log4j2 2.14 版本如何绑定

在 Springmvc 开发中 slf4j-api 1.8+ 和 log4j2 2.14 版本如何绑定

資深大佬 : NoKey 11

今天搭建了一个 spring mvc 工程(不是 springboot )

在 mvnrepository 找了 slf4j 和 log4j2 的包

把最新版本拿了下来

pom.xml 里面按照习惯这样写的

     <dependency>       <groupId>org.apache.logging.log4j</groupId>       <artifactId>log4j-core</artifactId>       <version>2.14.0</version>     </dependency>      <dependency>       <groupId>org.apache.logging.log4j</groupId>       <artifactId>log4j-api</artifactId>       <version>2.14.0</version>     </dependency>      <dependency>       <groupId>org.apache.logging.log4j</groupId>       <artifactId>log4j-slf4j-impl</artifactId>       <version>2.14.0</version>     </dependency>       <dependency>       <groupId>org.slf4j</groupId>       <artifactId>slf4j-api</artifactId>       <version>2.0.0-alpha1</version>     </dependency>   

运行起来有提示

SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details. SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8. SLF4J: Ignoring binding found at [jar:file:/Users/xxx/develop/code/myservice/target/myservice/WEB-INF/lib/log4j-slf4j-impl-2.14.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation. 

然后,我根据提示的连接进去看了一下,有个说明

Planning for the advent of Jigsaw (Java 9), slf4j-api version 1.8.x and later use the ServiceLoader mechanism. Earlier versions of SLF4J relied on the static binder mechanism which is no longer honored by slf4j-api. In case SLF4J finds no providers targeting SLF4J 1.8 but finds instead bindings targeting SLF4J 1.7 or earlier, it will list the bindings it finds but otherwise ignores them. 

学艺不精。。。没搞懂我到底应该怎么做

请各位大佬赐教。。。谢谢。

大佬有話說 (2)

  • 資深大佬 : skydiver

    应该是用这个包 https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j18-impl

  • 主 資深大佬 : NoKey

    @skydiver 谢谢,我昨天尝试过这个包,还是有问题,可能是我启动工程有问题,今天重新启动一下就 ok 了

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具