springboot2配置log4j2报错

时间:2024-04-04 08:14:56

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/DevSpace/M2Space/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/DevSpace/M2Space/org/apache/logging/log4j/log4j-slf4j-impl/2.10.0/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
13:55:11.713 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
13:55:11.721 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/, /spring-boot/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter/target/classes/]
13:55:11.722 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/D:/CodeSpace/photobuyapi/target/classes/]
Logging system failed to initialize using configuration from ‘classpath:log4j2.xml’
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in [email protected]:17 - no applicable action for [properties], current ElementPath is [[configuration][properties]]
ERROR in [email protected]:35 - no applicable action for [property], current ElementPath is [[configuration][properties][property]]
ERROR in [email protected]:16 - no applicable action for [appenders], current ElementPath is [[configuration][appenders]]
ERROR in [email protected]:53 - no applicable action for [Console], current ElementPath is [[configuration][appenders][Console]]
ERROR in [email protected]:92 - no applicable action for [PatternLayout], current ElementPath is [[configuration][appenders][Console][PatternLayout]]

解决:
主要是jar包冲突,找到spring-boot-starter、spring-boot-starter-test、spring-boot-starter-web去掉默认配置


org.springframework.boot
spring-boot-starter-logging


ch.qos.logback
logback-access


ch.qos.logback
logback-core


ch.qos.logback
logback-classic



排除冲突的jar包
springboot2配置log4j2报错
如果发现如图中jar还存在,仍需要继续排除
springboot2配置log4j2报错