当前位置:网站首页>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>
边栏推荐
- 目标检测技术研究现状及发展趋势
- HDU 5655 CA Loves Stick
- 【bug】汇总Elipse项目中代码中文乱码解决方法!
- HDU 5655 CA Loves Stick
- CAS: 1192802-98-4 _uv cracking of biotin - PEG2 - azide
- 剑指offer第22题-链表中倒数第K个节点
- 《数字经济全景白皮书》金融数字用户篇 重磅发布!
- Pay from 0 to 1
- Unification of east-west and north-south communications
- encapsulation, package, access modifier, static variable
猜你喜欢
2022的七夕,奉上7个精美的表白代码,同时教大家快速改源码自用
21天打卡挑战学习MySQL——《Window下安装MySql》第一周 第三篇
noip初赛
E-commerce data warehouse ODS layer-----log data loading
Cisco ike2 IPSec configuration
for循环练习题
2022-08-02 mysql/stonedb slow SQL-Q18 - memory usage surge analysis
【刷题篇】二叉树的右视图
Bytebase database schema change management tool
noip preliminary round
随机推荐
382. Linked List Random Node
斩获双奖|易知微荣获“2021中国数字孪生解决方案优秀供应商”“中国智能制造优秀推荐产品”双奖项!
东西向和南北向通信的统一
【历史上的今天】8 月 3 日:微软研究院的创始人诞生;陌陌正式上线;苹果发布 Newton OS
CAS: 773888-45-2_BIOTIN ALKYNE_生物素-炔基
113. Teach a Man how to fish - How to query the documentation and technical implementation details of any SAP UI5 control property by yourself
Embedded systems: overview
Golang第二章:程序结构
Data_web(九)mongodb增量同步到mongodb
Data_web(八)mysql增量同步到mongodb
数据一致性:双删为什么要延时?
一文带你了解软件测试是干什么的?薪资高不高?0基础怎么学?
HCIP第十六天
mysql如何将表结构导出到excel
七夕快乐!
关于IDO预售系统开发技术讲解丨浅谈IDO预售合约系统开发原理分析
深度学习和机器学习有什么区别?
FinClip最易用的智能电视小程序
藏宝计划TreasureProject(TPC)系统模式开发技术原理
嵌入式系统:概述