当前位置:网站首页>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>
边栏推荐
- Optimize the query (work in progress)
- 投资性大于游戏性 NFT游戏到底是不是门好生意
- Makefile
- 【MySQL进阶】数据库与表的创建和管理
- 472. Concatenated Words
- golang写的存储引擎,基于b+树,mmap
- Shell编程的条件语句
- Live Preview | Build Business Intelligence, Quickly Embrace Financial Digital Transformation
- websocket多线程发送消息报错TEXT_PARTIAL_WRITING--自旋锁替换synchronized独占锁的使用案例
- Embedded systems: overview
猜你喜欢
113. 授人以渔 - 如何自行查询任意 SAP UI5 控件属性的文档和技术实现细节
嵌入式系统:时钟
如何设计 DAO 的 PoW 评判标准 并平衡不可能三角
Canvas App中点击图标生成PDF并保存到Dataverse中
Boss: There are too many systems in the company, can you realize account interoperability?
LabVIEW代码生成错误 61056
Adobe是什么?
Quickly build a website with static files
PowerMockup 4.3.4::::Crack
HCIP第十四天
随机推荐
encapsulation, package, access modifier, static variable
Golang Chapter 2: Program Structure
2019年10月SQL注入的两倍
Research status of target detection at home and abroad
嵌入式开发:嵌入式基础——代码和数据空间揭秘
Nine ways to teach you to read the file path in the resources directory
Kubernetes入门到精通-Operator 模式
376. Wiggle Subsequence
【day6】类与对象、封装、构造方法
UVa 437 - The Tower of Babylon (White Book)
用于流动质押和收益生成的 Web3 基础设施
中国企业构建边缘计算解决方案的最佳实践
21天打卡挑战学习MySQL——《Window下安装MySql》第一周 第三篇
关于Yii2批量更新的操作
HDU 5655 CA Loves Stick
【bug】汇总Elipse项目中代码中文乱码解决方法!
UVa 1025 - A Spy in the Metro(白书)
Quickly build a website with static files
113. 授人以渔 - 如何自行查询任意 SAP UI5 控件属性的文档和技术实现细节
for循环练习题