今天在springboot项目中替换log4j2日志的时候遇见的问题,闲话不多说。

错误日志

Logging system failed to initialize using configuration from 'classpath:log4j2-dev.xml'
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter@3:16 - no applicable action for [appenders], current ElementPath  is [[configuration][appenders]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:67 - no applicable action for [Console], current ElementPath  is [[configuration][appenders][Console]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@5:96 - no applicable action for [PatternLayout], current ElementPath  is [[configuration][appenders][Console][PatternLayout]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@10:119 - no applicable action for [RollingFile], current ElementPath  is [[configuration][appenders][RollingFile]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@11:96 - no applicable action for [PatternLayout], current ElementPath  is [[configuration][appenders][RollingFile][PatternLayout]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@12:23 - no applicable action for [Policies], current ElementPath  is [[configuration][appenders][RollingFile][Policies]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@13:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@14:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@16:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath  is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@21:79 - no applicable action for [RollingFile], current ElementPath  is [[configuration][appenders][RollingFile]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@22:96 - no applicable action for [PatternLayout], current ElementPath  is [[configuration][appenders][RollingFile][PatternLayout]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@23:23 - no applicable action for [Policies], current ElementPath  is [[configuration][appenders][RollingFile][Policies]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@24:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@25:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@27:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath  is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@28:79 - no applicable action for [ThresholdFilter], current ElementPath  is [[configuration][appenders][RollingFile][ThresholdFilter]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@32:14 - no applicable action for [loggers], current ElementPath  is [[configuration][loggers]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@36:64 - no applicable action for [logger], current ElementPath  is [[configuration][loggers][logger]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@37:42 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@38:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@39:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@43:77 - no applicable action for [logger], current ElementPath  is [[configuration][loggers][logger]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@44:42 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@50:28 - no applicable action for [root], current ElementPath  is [[configuration][loggers][root]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@52:42 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][root][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@53:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][root][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@54:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][root][appender-ref]]at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:162)at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:56)at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:114)at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:309)at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:277)at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:240)at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:213)at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:121)at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)at org.junit.runners.ParentRunner.run(ParentRunner.java:363)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)at org.junit.runner.JUnitCore.run(JUnitCore.java:137)at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)java.lang.IllegalStateException: Failed to load ApplicationContextat org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)at org.junit.runners.ParentRunner.run(ParentRunner.java:363)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)at org.junit.runner.JUnitCore.run(JUnitCore.java:137)at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter@3:16 - no applicable action for [appenders], current ElementPath  is [[configuration][appenders]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:67 - no applicable action for [Console], current ElementPath  is [[configuration][appenders][Console]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@5:96 - no applicable action for [PatternLayout], current ElementPath  is [[configuration][appenders][Console][PatternLayout]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@10:119 - no applicable action for [RollingFile], current ElementPath  is [[configuration][appenders][RollingFile]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@11:96 - no applicable action for [PatternLayout], current ElementPath  is [[configuration][appenders][RollingFile][PatternLayout]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@12:23 - no applicable action for [Policies], current ElementPath  is [[configuration][appenders][RollingFile][Policies]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@13:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@14:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@16:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath  is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@21:79 - no applicable action for [RollingFile], current ElementPath  is [[configuration][appenders][RollingFile]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@22:96 - no applicable action for [PatternLayout], current ElementPath  is [[configuration][appenders][RollingFile][PatternLayout]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@23:23 - no applicable action for [Policies], current ElementPath  is [[configuration][appenders][RollingFile][Policies]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@24:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@25:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@27:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath  is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@28:79 - no applicable action for [ThresholdFilter], current ElementPath  is [[configuration][appenders][RollingFile][ThresholdFilter]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@32:14 - no applicable action for [loggers], current ElementPath  is [[configuration][loggers]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@36:64 - no applicable action for [logger], current ElementPath  is [[configuration][loggers][logger]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@37:42 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@38:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@39:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@43:77 - no applicable action for [logger], current ElementPath  is [[configuration][loggers][logger]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@44:42 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@50:28 - no applicable action for [root], current ElementPath  is [[configuration][loggers][root]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@52:42 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][root][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@53:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][root][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@54:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][root][appender-ref]]at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:316)at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:277)at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:240)at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:213)at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:121)at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)... 24 more
Caused by: java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter@3:16 - no applicable action for [appenders], current ElementPath  is [[configuration][appenders]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:67 - no applicable action for [Console], current ElementPath  is [[configuration][appenders][Console]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@5:96 - no applicable action for [PatternLayout], current ElementPath  is [[configuration][appenders][Console][PatternLayout]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@10:119 - no applicable action for [RollingFile], current ElementPath  is [[configuration][appenders][RollingFile]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@11:96 - no applicable action for [PatternLayout], current ElementPath  is [[configuration][appenders][RollingFile][PatternLayout]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@12:23 - no applicable action for [Policies], current ElementPath  is [[configuration][appenders][RollingFile][Policies]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@13:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@14:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@16:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath  is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@21:79 - no applicable action for [RollingFile], current ElementPath  is [[configuration][appenders][RollingFile]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@22:96 - no applicable action for [PatternLayout], current ElementPath  is [[configuration][appenders][RollingFile][PatternLayout]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@23:23 - no applicable action for [Policies], current ElementPath  is [[configuration][appenders][RollingFile][Policies]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@24:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@25:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath  is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@27:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath  is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@28:79 - no applicable action for [ThresholdFilter], current ElementPath  is [[configuration][appenders][RollingFile][ThresholdFilter]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@32:14 - no applicable action for [loggers], current ElementPath  is [[configuration][loggers]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@36:64 - no applicable action for [logger], current ElementPath  is [[configuration][loggers][logger]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@37:42 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@38:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@39:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@43:77 - no applicable action for [logger], current ElementPath  is [[configuration][loggers][logger]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@44:42 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][logger][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@50:28 - no applicable action for [root], current ElementPath  is [[configuration][loggers][root]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@52:42 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][root][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@53:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][root][appender-ref]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@54:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][loggers][root][appender-ref]]at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:162)at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:56)at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:114)at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:309)... 38 moreDisconnected from the target VM, address: '127.0.0.1:65035', transport: 'socket'Process finished with exit code -1

首先我们看上面的错误日志

Logging system failed to initialize using configuration from 'classpath:log4j2-dev.xml'
java.lang.IllegalStateException: Logback configuration error detected:

如果只看这两句的话我们可能会认为是我们的日志文件log4j2-dev.xml配置错了,或者路径找不到,其实不然。正解是我们pom文件配置的有问题,jar包存在冲突,下面来看下我们的pom文件吧

pom.xml

     <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-log4j2</artifactId></dependency>

上面的pom文件是最初报错时的配置文件,看上面的配置文件貌似没有问题,我们需使用log4j2日志的starter也已经引入了,但是这里我们需要注意一点就是我们在引入spring-boot-starter-web包的时候他里面默认使用了logback日志,这样就会产生日志包的冲突,其实不只是starter-web包默认引入的logback还有很多的包默认引入的logback包,看下图

上图中是这个pom文件的jiar包结构示意图,log4j2部分就是我们新引入的spring-boot-starter-log4j2包,上图中我通过黄线画出了现在系统中所有logback的引入,可以看出所有引用,这里涉及到几个包,分别是web包,mybatis包,jdbc包。那我们现在要解决jar包冲突的问题是不是需要每个包下都排除默认引用的logger日志呢,理论上是完全没有问题的,但是那样岂不是很费事,解决办法

解决办法1

统一排除

     <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-logging</artifactId></exclusion></exclusions></dependency>

解决办法2

那我只导用了web包,不想导入spring-boot-starter能不能解决呢?
答 : 能

         <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-logging</artifactId></exclusion></exclusions></dependency>

看见第二个解决办法,问题是不是来了。很多包都默认使用的logback,你单独排除了web包是不是还会出现这个问题,
答 : 是的会出现,这里就需要知道pom文件的加载顺序了,pom文件的加载顺序也是从上至下执行,那么我们就需要把web包放到pom文件中的第一位,在向下执行的时候也会排除所有的默认logger了。

上面就是两种解决办法。虚心向大家学习

Logback configuration error detected的终极解决方案相关推荐

  1. springboot配置log4j2报错:java.lang.IllegalStateException: Logback configuration error detected:

    引入log4j2后启动报错. Exception in thread "main" java.lang.IllegalStateException: java.lang.Illeg ...

  2. springboot集成logback,报错java.lang.IllegalStateException: Logback configuration error detected:

    最近需要将一个springboot项目部署到一台新服务器上.而且新服务器是完全copy了旧服务器的环境与项目.但是在新服务器上启动该springboot项目,就一直报错 2019-03-18 18:5 ...

  3. Spring Boot与Log4j2集成之java.lang.IllegalStateException: Logback configuration error detected:

    引言: 一个问题的分析与解决过程是表与里的过程,是一个大胆猜测与小心求证的过程,spring boot与log4j2的集成过程中,我将描述一下分析这个问题的思路和过程. 我一直强调一点: 重要的不是解 ...

  4. logback启动报错,IllegalStateException: Logback configuration error detected...

    报错信息: Caused by: java.lang.IllegalStateException: Logback configuration error detected: ERROR in ch. ...

  5. Logback configuration error detected:

    使用spring cloud alibaba微服务时,配置日志时可能会出现 Logback configuration error detected: 'File' option has the sa ...

  6. 亚马逊的PuTTY连接AWS出现network error connection refused,终极解决方案。

    亚马逊的PuTTY连接AWS出现network error connection refused,终极解决方案. 参考文章: (1)亚马逊的PuTTY连接AWS出现network error conn ...

  7. vue项目yarn初始化项目报错error D:\xxx\node_modules\node-sass;终极解决方案

    问题:入职公司,接手项目yarn初始化项目一直失败崩溃啊!!!!!!! 报错内容: error D:\xxx\xxx\node_modules\node-sass: Command failed. E ...

  8. fatal error LNK1169: one or more multiply defined symbols found 终极解决方案

    fatal error LNK1169: one or more multiply defined symbols found 终极解决方案 参考文章: (1)fatal error LNK1169: ...

  9. 终极解决方案:Emacs+Slime+Lisp启动错误:Polling /tmp/slime.50

    2019独角兽企业重金招聘Python工程师标准>>> 终极解决方案:Emacs+Slime+Lisp启动错误:Polling "/tmp/slime.5000 .. 25 ...

最新文章

  1. 今天是我“略懂”Python的第200天,我遇到了新刺激……
  2. 华为内部面试题库---(19)
  3. 转:使用XMLSerializer类持久化数据
  4. Github如何更新Fork的仓库
  5. 软件工程专插本_2021年广东专插本8所学校招生专业(拟),华师停招专插本?...
  6. MMO移动游戏性能分析报告:渲染、UI、逻辑代码和内存
  7. mvc报错:403.14-Forbidden Web 服务器被配置为不列出此目录的内容
  8. 自动化测试项目实战训练【广州8月】
  9. css字体浏览(转)
  10. Maven 教程:IDEA开发环境中maven 项目配置JDK9,JDK10,JDK11,JDK12..等EA版本的配置方法 系列教程二
  11. 自适应滤波器(一)LMS自适应滤波器
  12. 实用常识 | 写论文时如何引用插入脚注 / 如何自定义脚注符号 / 如何将多个脚注合并在一起
  13. 客房预订管理系统(一)
  14. 物联网应用之远程控制
  15. python invalid syntax 冒号_SyntaxError: invalid syntax python【解决方法】 – IT热血青年
  16. 日记(docker)
  17. python数据框提取子集_pandas 数据子集的获取
  18. Proteus VSM Studio汇编 + 8位数码管时钟按键可调
  19. 大连理工优化方法matlab,大连理工大学庞丽萍最优化方法matlab程序.doc
  20. 【自制分享】开源mini esp8266 天气时钟

热门文章

  1. Android apk签名方法介绍
  2. python zip暴力破解
  3. 题目十:从字符串2中找出字符串1中的所有字符并按ASCII排序
  4. 量子计算机新宇宙,脑洞大开!未来的量子计算机将运行在平行宇宙里
  5. pyautogui 滑动页面_pyautogui 使用方法简记
  6. C#-FFmpeg-视频添加logo
  7. ubuntu18.04调节系统声音大小
  8. linux时间同步服务z
  9. 【阿里云】阿里云物联网平台参数设置
  10. 【blender建模功能】00 编辑模式点线面与统计信息拓展