当前位置:网站首页>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>
边栏推荐
- .NET6之MiniAPI(十四):跨域CORS(上)
- start with connect by implements recursive query
- 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
- Data_web(八)mysql增量同步到mongodb
- Go开发工具GoLand V2022.2 来了——Go 工作区重大升级
- 藏宝计划TreasureProject(TPC)系统模式开发技术原理
- 深度学习和机器学习有什么区别?
- 剑指offer第22题-链表中倒数第K个节点
- mysql如何将表结构导出到excel
- 『百日百题 · 基础篇』备战面试,坚持刷题 第四话——循环语句!
猜你喜欢

《数字经济全景白皮书》金融数字用户篇 重磅发布!
![navicat 连接 mongodb 报错[13][Unauthorized] command listDatabases requires authentication](/img/09/a579c60e07cdc145175e72673409f7.png)
navicat 连接 mongodb 报错[13][Unauthorized] command listDatabases requires authentication

如何创建一个Web项目

for循环练习题

Canvas App中点击图标生成PDF并保存到Dataverse中

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

藏宝计划TreasureProject(TPC)系统模式开发技术原理

CAS:1260586-88-6_Biotin-C5-Azide_Biotin-C5-Azide

encapsulation, package, access modifier, static variable

What is Adobe?
随机推荐
电商秒杀系统
for loop exercises
JPA Native Query(本地查询)及查询结果转换
CAS:1620523-64-9_Azide-SS-biotin_biotin-disulfide-azide
【bug】汇总Elipse项目中代码中文乱码解决方法!
静态文件快速建站
pikachu Over permission 越权
[b01lers2020]Life on Mars
21天打卡挑战学习MySQL—Day第一周 第一篇
2022-08-02 mysql/stonedb慢SQL-Q18-内存使用暴涨分析
How to write a database document management tool based on WPF (2)
HCIP第十六天
384. Shuffle an Array
Diazo Biotin-PEG3-DBCO | Diazo Compound Modified Biotin-Tripolyethylene Glycol-Dibenzocyclooctyne
CAS:122567-66-2_DSPE-Biotin_DSPE-Biotin
Network basic learning series four (network layer, data link layer and some other important protocols or technologies)
2022-08-03 Oracle executes slow SQL-Q17 comparison
剑指offer第22题-链表中倒数第K个节点
CAS: 1192802-98-4 _uv cracking of biotin - PEG2 - azide
noip初赛