当前位置:网站首页>Upgrade log4j2 to 2.17.1 stepped pit
Upgrade log4j2 to 2.17.1 stepped pit
2022-06-30 09:47:00 【A grain of sand in the vast sea of people】
Catalog
1. If you're using a spring boot2.x How to upgrade conveniently
2. Caused by: java.lang.NoSuchMethodError: com.lmax.disruptor.dsl.Disruptor
3. Log4j2 error- ERROR StatusLogger Unrecognized format specifier
edition
| Library | Current | Upgraded |
| Lo4j2 related jar | * | 2.17.1 |
1. If you're using a spring boot2.x How to upgrade conveniently
stay pom.xml Riga log4j2.version attribute , overwrite spring-boot-starter-parent The specified version of .
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<log4j2.version>2.17.1</log4j2.version>
</properties>as a result of :
spring-boot-dependendencies.pom It's defined in log4j2.version attribute , Use its value to add log4j2 Related to the package .
....
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.6.2</version>
<packaging>pom</packaging>
...
<properties>
...
<log4j2.version>2.17.0</log4j2.version>
<logback.version>1.2.9</logback.version>
<lombok.version>1.18.22</lombok.version>
<slf4j.version>1.7.32</slf4j.version>
...
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>${log4j2.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
stay log4j-bom.pom In fact, it puts all log4j All related packages have been added . So you can use it directly in our project .
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
....
<dependencyManagement>
<dependencies>
<!-- Log4j API -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Core Log4j -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${project.version}</version>
</dependency>
.....
<!-- Legacy Log4j 1.2 API -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Commons Logging Compatibility API -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>${project.version}</version>
</dependency>
<!-- SLF4J Compatibility API -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${project.version}</version>
</dependency>
<!-- SLF4J 1.8.x Compatibility API -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j18-impl</artifactId>
<version>${project.version}</version>
</dependency>
<!-- SLF4J Adapter -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Web Application Support -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>${project.version}</version>
</dependency>
<!-- java.util.logging adapter -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
<version>${project.version}</version>
</dependency>
....
</dependencies>
</dependencyManagement>If you don't know much about <scope>import</scope> The meaning of , Take a look at the following introduction , It's very clear
Maven – Introduction to the Dependency Mechanism
2. Caused by: java.lang.NoSuchMethodError: com.lmax.disruptor.dsl.Disruptor
Abnormal information :
Caused by: java.lang.NoSuchMethodError: com.lmax.disruptor.dsl.Disruptor.<init>(Lcom/lmax/disruptor/EventFactory;ILjava/util/concurrent/ThreadFactory;Lcom/lmax/disruptor/dsl/ProducerType;Lcom/lmax/disruptor/WaitStrategy;)V
reason :
The project USES log4j2, Due to the use of global asynchronous log printing , It also needs to be introduced disruptor Dependence
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.2.0</version>
</dependency>
log4j2.xml
<Loggers>
<AsyncRoot level="INFO" includeLocation="true">
<AppenderRef ref="stdout" />
<AppenderRef ref="file" />
</AsyncRoot>
</Loggers>resolvent :
upgrade Disruptor To 3.4.0 edition
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.0</version>
</dependency>
3. Log4j2 error- ERROR StatusLogger Unrecognized format specifier
error message :
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
ERROR StatusLogger Reconfiguration failed: No configuration found for '135fbaa4' at 'null' in 'null'
Related codes - pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>your-component-name</finalName>
</configuration>
</execution>
</executions>
</plugin>resolvent :
Remove when packing Log4j2Plugins.dat file .
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>your-component-name</finalName>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>**/Log4j2Plugins.dat</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>边栏推荐
- Redis docker 主从模式与哨兵sentinel
- Solution to pychart's failure in importing torch package
- 【Ubuntu-redis安装】
- 【新书推荐】Cleaning Data for Effective Data Science
- MCU firmware packaging Script Software
- Distributed ID
- Net framework system requirements
- Idea shortcut key settings
- [new book recommendation] cleaning data for effective data science
- Express get request
猜你喜欢
![[new book recommendation] DeNO web development](/img/86/27906ae378e597cf64bb2d760a9dff.png)
[new book recommendation] DeNO web development

Express - static resource request
![[new book recommendation] cleaning data for effective data science](/img/42/1258694fc55a178a666391669a67ad.png)
[new book recommendation] cleaning data for effective data science

Oracle cross database replication data table dblink

Deberta (decoding enhanced Bert with distinguished attention)

【Ubuntu-redis安装】

单片机 MCU 固件打包脚本软件

Acquisition de 100% des actions de Guilin latex par Guilin Robust Medical pour combler le vide de la gamme de produits Latex

Good partner for cloud skill improvement, senior brother cloud of Amazon officially opened today

八大排序(一)
随机推荐
MySQL explain
Small program development journey
oracle跨数据库复制数据表-dblink
Work notes: SendTo failed errno 22
桂林 穩健醫療收購桂林乳膠100%股權 填補乳膠產品線空白
Torch learning summary
MySQL-- Entity Framework Code First(EF Code First)
Idea setting automatic package Guide
Why won't gold depreciate???
Express - static resource request
About the smart platform solution for business hall Terminal Desktop System
MCU firmware packaging Script Software
桂林 稳健医疗收购桂林乳胶100%股权 填补乳胶产品线空白
Mysq database remote connection error, remote connection is not allowed
MySQL index optimization miscellaneous
Niuke walks on the tree (ingenious application of parallel search)
Redis docker master-slave mode and sentinel
Abstract classes and interfaces
Deberta (decoding enhanced Bert with distinguished attention)
JVM family