文章目录
- 一、. 普通web项目
- 1. 下载依赖
- 2. 解压
- 3.更新操作
- 4.移除旧依赖
- 5. 更新包
- 二. maven项目修复
- 2.1. maven 项目
- 2.2. 微服务项目
一、. 普通web项目
下载官网:https://logging.apache.org/log4j/2.x/download.html
1. 下载依赖
wget https://dlcdn.apache.org/logging/log4j/2.17.1/apache-log4j-2.17.1-bin.zip
2. 解压
unzip apache-log4j-2.17.1-bin.zip
3.更新操作
以a-boot微服务为例:
cd /app/a-boot/webapps/WEB-INF/lib;
ls -al log4j-*
4.移除旧依赖
移除jar包:
mv log4j-api* /tmp;mv log4j-core* /tmp;mv log4j-jul* /tmp;mv log4j-slf4j-impl-* /tmp;
5. 更新包
cp /app/apache-log4j-2.17.1-bin/log4j-api-2.17.1.jar ./cp /app/apache-log4j-2.17.1-bin/log4j-core-2.17.1.jar ./cp /app/apache-log4j-2.17.1-bin/log4j-jul-2.17.1.jar ./cp /app/apache-log4j-2.17.1-bin/log4j-slf4j-impl-2.17.1.jar ./
二. maven项目修复
- 替换旧版本依赖
2.1. maven 项目
<properties><log4j2.version>2.17.1</log4j2.version></properties><dependency><groupId>org.apache.logging.log4j</groupId><artifactId>log4j-api</artifactId><version>${log4j2.version}</version></dependency><dependency><groupId>org.apache.logging.log4j</groupId><artifactId>log4j-core</artifactId><version>${log4j2.version}</version></dependency><dependency><groupId>org.apache.logging.log4j</groupId><artifactId>log4j-jul</artifactId><version>${log4j2.version}</version></dependency><dependency><groupId>org.apache.logging.log4j</groupId><artifactId>log4j-slf4j-impl</artifactId><version>${log4j2.version}</version></dependency>
2.2. 微服务项目
- 为微服务项目,指定依赖版本
默认
解决方案
<properties><log4j2.version>2.17.1</log4j2.version></properties><!--log4j2--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-log4j2</artifactId></dependency>