目录
1. 如果你用的是spring boot2.x 怎么升级方便
2. Caused by: java.lang.NoSuchMethodError: com.lmax.disruptor.dsl.Disruptor
3. Log4j2 error- ERROR StatusLogger Unrecognized format specifier
版本
| Library | Current | Upgraded |
| Lo4j2 related jar | * | 2.17.1 |
1. 如果你用的是spring boot2.x 怎么升级方便
在pom.xml里加log4j2.version属性, 覆盖掉spring-boot-starter-parent的指定版本。
org.springframework.boot spring-boot-starter-parent2.6.2 2.17.1
原因是:
spring-boot-dependendencies.pom里定义了 log4j2.version属性,利用它的值加的log4j2相关的包。
....org.springframework.boot spring-boot-dependencies2.6.2 pom ...... 2.17.0 1.2.9 1.18.22 1.7.32 ...org.apache.logging.log4j log4j-bom${log4j2.version} pom import
在 log4j-bom.pom 里其实它把所有的log4j相关包都加了。所以在我们的项目你直接用就可以了。
org.apache.logging.log4j log4j-bom ....org.apache.logging.log4j log4j-api${project.version} ..... org.apache.logging.log4j log4j-core${project.version} org.apache.logging.log4j log4j-1.2-api${project.version} org.apache.logging.log4j log4j-jcl${project.version} org.apache.logging.log4j log4j-slf4j-impl${project.version} org.apache.logging.log4j log4j-slf4j18-impl${project.version} org.apache.logging.log4j log4j-to-slf4j${project.version} org.apache.logging.log4j log4j-web${project.version} .... org.apache.logging.log4j log4j-jul${project.version}
如果你不是很了解
Maven – Introduction to the Dependency Mechanism
2. Caused by: java.lang.NoSuchMethodError: com.lmax.disruptor.dsl.Disruptor
异常信息:
Caused by: java.lang.NoSuchMethodError: com.lmax.disruptor.dsl.Disruptor.
原因:
项目使用了log4j2,由于使用了全局异步打印日志的方式,还需要引入disruptor的依赖
com.lmax disruptor3.2.0
log4j2.xml
解决方法:
升级Disruptor 到3.4.0 版本
com.lmax disruptor3.4.0
3. Log4j2 error- ERROR StatusLogger Unrecognized format specifier
错误信息:
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'
相关代码- pom.xml
org.apache.maven.plugins maven-shade-pluginpackage shade your-component-name
解决方法:
打包的时候去掉Log4j2Plugins.dat 文件。
org.apache.maven.plugins maven-shade-pluginpackage shade your-component-name *:* **/Log4j2Plugins.dat



