当前位置:网站首页>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
- 113. Teach a Man how to fish - How to query the documentation and technical implementation details of any SAP UI5 control property by yourself
- 关于IDO预售系统开发技术讲解丨浅谈IDO预售合约系统开发原理分析
- 【刷题篇】二叉树的右视图
- Teach a Man How to Fish - How to Query the Properties of Any SAP UI5 Control by Yourself Documentation and Technical Implementation Details Demo
- 决策树、GBDT、XGBOOST树的可视化
- L2-029 特立独行的幸福
- 一些思考:腾讯股价为何持续都低
- encapsulation, package, access modifier, static variable
- 472. Concatenated Words
猜你喜欢

易观分析:2022年Q2中国网络零售B2C市场交易规模达23444.7亿元

HCIP第十六天

2022的七夕,奉上7个精美的表白代码,同时教大家快速改源码自用

授人以渔 - 如何自行查询任意 SAP UI5 控件属性的文档和技术实现细节试读版

noip preliminary round

静态文件快速建站

encapsulation, package, access modifier, static variable

113. Teach a Man how to fish - How to query the documentation and technical implementation details of any SAP UI5 control property by yourself
![[MySQL Advanced] Creation and Management of Databases and Tables](/img/31/2015122e409148b3679b09a03db869.png)
[MySQL Advanced] Creation and Management of Databases and Tables

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
随机推荐
FinClip最易用的智能电视小程序
UVa 10003 - Cutting Sticks (White Book, Interval DP)
如何基于WPF写一款数据库文档管理工具(二)
Causes of Mysql Disk Holes and Several Ways to Rebuild Tables
斩获双奖|易知微荣获“2021中国数字孪生解决方案优秀供应商”“中国智能制造优秀推荐产品”双奖项!
《数字经济全景白皮书》金融数字用户篇 重磅发布!
480. Sliding Window Median
一些思考:腾讯股价为何持续都低
[MySQL Advanced] Creation and Management of Databases and Tables
DO280管理和监控OpenShift平台--资源限制
亿流量大考(2):开发一套高容错分布式系统
藏宝计划TreasureProject(TPC)系统模式开发技术原理
4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
优化查询(工作中)
Embedded Systems: Clocks
385. Mini Parser
Pay from 0 to 1
HDU 5655 CA Loves Stick
golang写的存储引擎,基于b+树,mmap
【云原生实用技巧】使用 skopeo 批量同步 helm chart 依赖镜像