当前位置:网站首页>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>
边栏推荐
- pikachu Over permission 越权
- 剑指offer第22题-链表中倒数第K个节点
- On the Qixi Festival of 2022, I will offer 7 exquisite confession codes, and at the same time teach you to quickly change the source code for your own use
- 【day6】类与对象、封装、构造方法
- 决策树、GBDT、XGBOOST树的可视化
- 21天打卡挑战学习MySQL—Day第一周 第一篇
- Flink--Join以及Flink函数
- Work Subtotal QT Packing
- UVa 1025 - A Spy in the Metro(白书)
- The development status of cloud computing at home and abroad
猜你喜欢
随机推荐
直播预告 | 构建业务智联,快速拥抱财务数字化转型
"Digital Economy Panorama White Paper" Financial Digital User Chapter released!
utils timer
为什么我们需要回调
HCIP第十三天
中国企业构建边缘计算解决方案的最佳实践
mysql如何将表结构导出到excel
Golang第一章:入门
The development status of cloud computing at home and abroad
藏宝计划TreasureProject(TPC)系统模式开发技术原理
MiniAPI of .NET6 (14): Cross-domain CORS (Part 1)
投资性大于游戏性 NFT游戏到底是不是门好生意
Makefile
目标检测的国内外研究现状
用于流动质押和收益生成的 Web3 基础设施
What is the difference between the generator version and the viewer version?
Nine ways to teach you to read the file path in the resources directory
The sword refers to the offer question 22 - the Kth node from the bottom in the linked list
Boss: There are too many systems in the company, can you realize account interoperability?
113. Teach a Man how to fish - How to query the documentation and technical implementation details of any SAP UI5 control property by yourself




![[N1CTF 2018] eating_cms](/img/09/3599d889d9007eb45c6eab3043f0c4.png)
![[b01lers2020]Life on Mars](/img/d0/d5c9b7224542c8843ce29adc7ef713.png)



