当前位置:网站首页>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>
边栏推荐
猜你喜欢

【MySQL进阶】数据库与表的创建和管理

2022-08-03 oracle执行慢SQL-Q17对比

深度学习和机器学习有什么区别?

YOLO之父宣布退出CV界,坦言无法忽视自己工作带来的负面影响

for loop exercises

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

超级实用网站+公众号合集

Boss: There are too many systems in the company, can you realize account interoperability?

生成器版和查看器版有什么区别?

Diazo Biotin-PEG3-DBCO | Diazo Compound Modified Biotin-Tripolyethylene Glycol-Dibenzocyclooctyne
随机推荐
IO thread process -> thread synchronization mutual exclusion mechanism -> day6
嵌入式系统:GPIO
投资性大于游戏性 NFT游戏到底是不是门好生意
【云原生实用技巧】使用 skopeo 批量同步 helm chart 依赖镜像
Cisco ike2 IPSec配置
藏宝计划TreasureProject(TPC)系统模式开发技术原理
目标检测的国内外研究现状
21天打卡挑战学习MySQL——《MySQL工具的使用》第一周 第二篇
【历史上的今天】8 月 3 日:微软研究院的创始人诞生;陌陌正式上线;苹果发布 Newton OS
VIM操作
21天打卡挑战学习MySQL—Day第一周 第一篇
超级实用网站+公众号合集
Lift, Splat, Shoot: Encoding Images from Arbitrary Camera Rigs by Implicitly Unprojecting to 3D 论文笔记
FinClip最易用的智能电视小程序
Summary bug 】 【 Elipse garbled solution project code in Chinese!
深度学习和机器学习有什么区别?
如何基于WPF写一款数据库文档管理工具(二)
376. Wiggle Subsequence
函数,递归以及dom简单操作
PowerMockup 4.3.4::::Crack