当前位置:网站首页>log4j-slf4j-impl cannot be present with log4j-to-slf4j
log4j-slf4j-impl cannot be present with log4j-to-slf4j
2022-08-03 22:22:00 【Master_Shifu_】
背景:
在修复logback远程执行漏洞时报错
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. 最复杂的方案是:逐个组件,挨个排查
如果springboot 项目使用log4j2日志框架,就将项目中引入 spring-boot-starter-logging及其引用jar 的地方,全部排查掉;或者继续使用springboot的logback,
那么就将log4j2 以及其jar的地方,通排查。— 耗时并且可能排查不干净
2. 使用pom全局排除
即将spring-boot-starter-logging 全部排除或者是将 spring-boot-starter-log4j2 的地方全部排除。
使用springboot 默认的logback 日志输出日志设置 :
<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>
边栏推荐
- UVa 10003 - Cutting Sticks (White Book, Interval DP)
- node连接mysql数据库报错:Client does not support authentication protocol requested by server
- Gains double award | know micro easily won the "2021 China digital twin solution suppliers in excellence" "made in China's smart excellent recommended products" double award!
- Cisco ike2 IPSec配置
- pikachu Over permission 越权
- [N1CTF 2018] eating_cms
- 东西向和南北向通信的统一
- Cisco ike2 IPSec configuration
- L2-029 特立独行的幸福
- 如何设计 DAO 的 PoW 评判标准 并平衡不可能三角
猜你喜欢

如何设计 DAO 的 PoW 评判标准 并平衡不可能三角
Causes of Mysql Disk Holes and Several Ways to Rebuild Tables

HCIP第十三天

2022-08-03 Oracle executes slow SQL-Q17 comparison

Diazo Biotin-PEG3-DBCO | Diazo Compound Modified Biotin-Tripolyethylene Glycol-Dibenzocyclooctyne

HCIP BGP实验报告

目标检测技术研究现状及发展趋势

PowerMockup 4.3.4::::Crack

【历史上的今天】8 月 3 日:微软研究院的创始人诞生;陌陌正式上线;苹果发布 Newton OS

2022-08-02 mysql/stonedb慢SQL-Q18-内存使用暴涨分析
随机推荐
UVa 10003 - Cutting Sticks (White Book, Interval DP)
CAS:1620523-64-9_Azide-SS-biotin_biotin-disulfide-azide
What is Adobe?
东西向和南北向通信的统一
UVa 10003 - Cutting Sticks(白书,区间DP)
Codeup brushing notes - simple simulation
golang写的存储引擎,基于b+树,mmap
IO thread process -> thread synchronization mutual exclusion mechanism -> day6
384. Shuffle an Array
Canvas App中点击图标生成PDF并保存到Dataverse中
Makefile
HDU 5655 CA Loves Stick
VIM操作
.NET6之MiniAPI(十四):跨域CORS(上)
HCIP第十五天
【进阶自动化测试】一文1000教你如何用Postman做接口自动化测试
静态文件快速建站
376. Wiggle Subsequence
start with connect by 实现递归查询
Golang Chapter 2: Program Structure