当前位置:网站首页>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>边栏推荐
- Eight sorts (II)
- QR code generation and analysis
- Self service terminal development process
- Recommend a very easy-to-use network communication framework HP socket
- MySQL knowledge summary (useful for thieves)
- Guilin robust medical acquired 100% equity of Guilin Latex to fill the blank of latex product line
- Machine learning note 9: prediction model optimization (to prevent under fitting and over fitting problems)
- 云技能提升好伙伴,亚马逊云师兄今天正式营业
- utlis 内存池 对象池
- 3.集成eslint、prettier
猜你喜欢

MySQL index and data storage structure foundation

Distributed ID

八大排序(二)

Express get request

Eight sorts (I)

I once met a girl whom I most wanted to take care of all my life. Later... No later

Solution to pychart's failure in importing torch package

Notes on masking and padding in tensorflow keras

Design of mfc+mysql document data management system based on VS2010

Challenge transform() 2D
随机推荐
小程序开发踩坑之旅
Redis docker 主从模式与哨兵sentinel
What makes flutter special
Niuke IOI weekly competition 20 popularization group (problem solving)
What is the difference between ZigBee, Bluetooth and WiFi (copy and reprint)
工作小记: sendto失败 errno 22
ABAP time function
Microsoft. Bcl. Async usage summary -- in Net framework 4.5 project Net framework version 4.5 and above can use async/await asynchronous feature in C 5
How to reduce the delay in live broadcast in the development of live broadcast source code with goods?
[new book recommendation] mongodb performance tuning
Code management related issues
(zero) most complete JVM knowledge points
Utlis memory pool object pool
直播带货源码开发中,如何降低直播中的延迟?
NTP of Prometheus monitoring_ exporter
Train an image classifier demo in pytorch [learning notes]
Properties of string
Deep Learning with Pytorch - autograd
DDD interview
Idea shortcut key settings