当前位置:网站首页>log4j-slf4j-impl cannot be present with log4j-to-slf4j
log4j-slf4j-impl cannot be present with log4j-to-slf4j
2022-08-03 22:27:00 【Master_Shifu_】
背景:
在修复logbackThe remote execution vulnerability reports an error
log4j-slf4j-impl cannot be present with log4j-to-slf4j
这个错误的意思是 log4j-slf4j-impl 和 log4j-to-slf4j 这两个包不能同时存在.
那么为什么这两个包不能同时存在呢?我们先来看一下这两个包的定义:
log4j-slf4j-impl
Apache Log4j SLF4J Binding: The Apache Log4j SLF4J API binding to Log4j 2 Core
log4j-to-slf4j
Apache Log4j to SLF4J Adapter: The Apache Log4j binding between Log4j 2 API and SLF4J
从上述定义可以看出,log4j-slf4j-impl 主要是 log4j 对 slf4j 接口的实现,而 log4j-to-slf4j 则是 slf4j 对 log4j 接口的适配.
解决方案
1. The most complicated scheme is:component by component,挨个排查
如果springboot 项目使用log4j2日志框架,imported into the project spring-boot-starter-logging及其引用jar 的地方,All checked out;或者继续使用springboot的logback,
那么就将log4j2 以及其jar的地方,Check through.— Time consuming and potentially dirty to troubleshoot
2. 使用pom全局排除
即将spring-boot-starter-logging All excluded or will be spring-boot-starter-log4j2 All places are excluded.
使用springboot 默认的logback Log output log settings :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 修复logback远程执行漏洞-->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.9</version>
<scope>compile</scope>
</dependency>
边栏推荐
- 获国际权威认可 | 云扩科技入选《RPA全球市场格局报告,Q3 2022》
- 互联网用户账号信息管理规定今起施行:必须严打账号买卖灰产
- Conditional Statements for Shell Programming
- 嵌入式系统:GPIO
- mysql如何将表结构导出到excel
- Diazo Biotin-PEG3-DBCO | Diazo Compound Modified Biotin-Tripolyethylene Glycol-Dibenzocyclooctyne
- 4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
- 376. Wiggle Subsequence
- Embedded Systems: Clocks
- Lift, Splat, Shoot: Encoding Images from Arbitrary Camera Rigs by Implicitly Unprojecting to 3D 论文笔记
猜你喜欢
随机推荐
Basic Concepts of Graphs
How to write a database document management tool based on WPF (2)
.NET6之MiniAPI(十四):跨域CORS(上)
【云原生实用技巧】使用 skopeo 批量同步 helm chart 依赖镜像
嵌入式系统:时钟
Makefile
HDU 5655 CA Loves Stick
pikachu Over permission 越权
Makefile
2022-08-03 oracle执行慢SQL-Q17对比
HDU 5655 CA Loves Stick
"Digital Economy Panorama White Paper" Financial Digital User Chapter released!
【刷题篇】二叉树的右视图
node连接mysql数据库报错:Client does not support authentication protocol requested by server
384. Shuffle an Array
Live Preview | Build Business Intelligence, Quickly Embrace Financial Digital Transformation
Summary bug 】 【 Elipse garbled solution project code in Chinese!
113. Teach a Man how to fish - How to query the documentation and technical implementation details of any SAP UI5 control property by yourself
override学习(父类和子类)
What is the difference between the generator version and the viewer version?