1. 程式人生 > >Logback configuration error detected的終極解決方案

Logback configuration error detected的終極解決方案

今天在springboot專案中替換log4j2日誌的時候遇見的問題,閒話不多說。

錯誤日誌

Logging system failed to initialize using configuration from 'classpath:log4j2-dev.xml'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in [email protected]:16 - no applicable action for [appenders], current ElementPath  is [[configuration][appenders]]
ERROR in 
[email protected]
:67 - no applicable action for [Console], current ElementPath is [[configuration][appenders][Console]] ERROR in [email protected]:96 - no applicable action for [PatternLayout], current ElementPath is [[configuration][appenders][Console][PatternLayout]] ERROR in [email protected]
:119 - no applicable action for [RollingFile], current ElementPath is [[configuration][appenders][RollingFile]] ERROR in [email protected]:96 - no applicable action for [PatternLayout], current ElementPath is [[configuration][appenders][RollingFile][PatternLayout]] ERROR in [email protected]
:23 - no applicable action for [Policies], current ElementPath is [[configuration][appenders][RollingFile][Policies]] ERROR in [email protected]:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]] ERROR in [email protected]:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]] ERROR in [email protected]:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]] ERROR in [email protected]:79 - no applicable action for [RollingFile], current ElementPath is [[configuration][appenders][RollingFile]] ERROR in [email protected]:96 - no applicable action for [PatternLayout], current ElementPath is [[configuration][appenders][RollingFile][PatternLayout]] ERROR in [email protected]:23 - no applicable action for [Policies], current ElementPath is [[configuration][appenders][RollingFile][Policies]] ERROR in [email protected]:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]] ERROR in [email protected]:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]] ERROR in [email protected]:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]] ERROR in [email protected]:79 - no applicable action for [ThresholdFilter], current ElementPath is [[configuration][appenders][RollingFile][ThresholdFilter]] ERROR in [email protected]:14 - no applicable action for [loggers], current ElementPath is [[configuration][loggers]] ERROR in [email protected]:64 - no applicable action for [logger], current ElementPath is [[configuration][loggers][logger]] ERROR in [email protected]:42 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:43 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:44 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:77 - no applicable action for [logger], current ElementPath is [[configuration][loggers][logger]] ERROR in [email protected]:42 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:28 - no applicable action for [root], current ElementPath is [[configuration][loggers][root]] ERROR in [email protected]:42 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][root][appender-ref]] ERROR in [email protected]:43 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][root][appender-ref]] ERROR in [email protected]: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 ApplicationContext at 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 [email protected]:16 - no applicable action for [appenders], current ElementPath is [[configuration][appenders]] ERROR in [email protected]:67 - no applicable action for [Console], current ElementPath is [[configuration][appenders][Console]] ERROR in [email protected]:96 - no applicable action for [PatternLayout], current ElementPath is [[configuration][appenders][Console][PatternLayout]] ERROR in [email protected]:119 - no applicable action for [RollingFile], current ElementPath is [[configuration][appenders][RollingFile]] ERROR in [email protected]:96 - no applicable action for [PatternLayout], current ElementPath is [[configuration][appenders][RollingFile][PatternLayout]] ERROR in [email protected]:23 - no applicable action for [Policies], current ElementPath is [[configuration][appenders][RollingFile][Policies]] ERROR in [email protected]:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]] ERROR in [email protected]:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]] ERROR in [email protected]:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]] ERROR in [email protected]:79 - no applicable action for [RollingFile], current ElementPath is [[configuration][appenders][RollingFile]] ERROR in [email protected]:96 - no applicable action for [PatternLayout], current ElementPath is [[configuration][appenders][RollingFile][PatternLayout]] ERROR in [email protected]:23 - no applicable action for [Policies], current ElementPath is [[configuration][appenders][RollingFile][Policies]] ERROR in [email protected]:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]] ERROR in [email protected]:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]] ERROR in [email protected]:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]] ERROR in [email protected]:79 - no applicable action for [ThresholdFilter], current ElementPath is [[configuration][appenders][RollingFile][ThresholdFilter]] ERROR in [email protected]:14 - no applicable action for [loggers], current ElementPath is [[configuration][loggers]] ERROR in [email protected]:64 - no applicable action for [logger], current ElementPath is [[configuration][loggers][logger]] ERROR in [email protected]:42 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:43 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:44 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:77 - no applicable action for [logger], current ElementPath is [[configuration][loggers][logger]] ERROR in [email protected]:42 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:28 - no applicable action for [root], current ElementPath is [[configuration][loggers][root]] ERROR in [email protected]:42 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][root][appender-ref]] ERROR in [email protected]:43 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][root][appender-ref]] ERROR in [email protected]: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 [email protected]:16 - no applicable action for [appenders], current ElementPath is [[configuration][appenders]] ERROR in [email protected]:67 - no applicable action for [Console], current ElementPath is [[configuration][appenders][Console]] ERROR in [email protected]:96 - no applicable action for [PatternLayout], current ElementPath is [[configuration][appenders][Console][PatternLayout]] ERROR in [email protected]:119 - no applicable action for [RollingFile], current ElementPath is [[configuration][appenders][RollingFile]] ERROR in [email protected]:96 - no applicable action for [PatternLayout], current ElementPath is [[configuration][appenders][RollingFile][PatternLayout]] ERROR in [email protected]:23 - no applicable action for [Policies], current ElementPath is [[configuration][appenders][RollingFile][Policies]] ERROR in [email protected]:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]] ERROR in [email protected]:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]] ERROR in [email protected]:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]] ERROR in [email protected]:79 - no applicable action for [RollingFile], current ElementPath is [[configuration][appenders][RollingFile]] ERROR in [email protected]:96 - no applicable action for [PatternLayout], current ElementPath is [[configuration][appenders][RollingFile][PatternLayout]] ERROR in [email protected]:23 - no applicable action for [Policies], current ElementPath is [[configuration][appenders][RollingFile][Policies]] ERROR in [email protected]:45 - no applicable action for [TimeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][TimeBasedTriggeringPolicy]] ERROR in ch.qos.logback.core.joran.spi.Interp[email protected]:57 - no applicable action for [SizeBasedTriggeringPolicy], current ElementPath is [[configuration][appenders][RollingFile][Policies][SizeBasedTriggeringPolicy]] ERROR in [email protected]:48 - no applicable action for [DefaultRolloverStrategy], current ElementPath is [[configuration][appenders][RollingFile][DefaultRolloverStrategy]] ERROR in [email protected]:79 - no applicable action for [ThresholdFilter], current ElementPath is [[configuration][appenders][RollingFile][ThresholdFilter]] ERROR in [email protected]:14 - no applicable action for [loggers], current ElementPath is [[configuration][loggers]] ERROR in [email protected]:64 - no applicable action for [logger], current ElementPath is [[configuration][loggers][logger]] ERROR in [email protected]:42 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:43 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:44 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:77 - no applicable action for [logger], current ElementPath is [[configuration][loggers][logger]] ERROR in [email protected]:42 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][logger][appender-ref]] ERROR in [email protected]:28 - no applicable action for [root], current ElementPath is [[configuration][loggers][root]] ERROR in [email protected]:42 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][root][appender-ref]] ERROR in [email protected]:43 - no applicable action for [appender-ref], current ElementPath is [[configuration][loggers][root][appender-ref]] ERROR in [email protected]: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 more Disconnected 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終極解決方案

今天在springboot專案中替換log4j2日誌的時候遇見的問題,閒話不多說。 錯誤日誌 Logging system failed to initialize using configuration from 'classpath:log4j2-dev.x

Spring Boot與Log4j2整合之java.lang.IllegalStateException: Logback configuration error detected:

引言: 一個問題的分析與解決過程是表與裡的過程,是一個大膽猜測與小心求證的過程,spring boot與log4j2的整合過程中,我將描述一下分析這個問題的思路和過程。 我一直強調一點: 重要的不是解決問題的結論,而是解決問題的思路和方法,即使在解決完問題之後,

異常:“ERROR: Permission to XXX.git denied to user”終極解決方案

錯誤:在學習github的時候,出現以下錯誤:分析:初看就是沒有許可權的問題,不能將本地版本庫的內容推送到遠端倉庫,後來才發現:是因為自己更換了遠端倉庫賬戶的原因,由於本地電腦的SSH公匙已經綁定了之前的那個賬戶(hy1106165661),就不能再繫結新的賬戶了。意思是你不

Error:Execution failed for task ':app:clean'. > Unable to delete directory 終極解決方案

<span style="font-size:12px;">Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSource

Unity 使用C/C++ 跨平臺終極解決方案(PC,iOS,Android,以及支持C/C++的平臺)

細節 -h comment 個人 tle lan source 多說 sharp https://blog.csdn.net/fg5823820/article/details/47865741 PC的其實根本不用說,畢竟C#和C++交互的文章已經夠多了,當然我自認為經過幾

(通用)Android App代碼混淆終極解決方案【轉】

rar $$ enable 知識 object ava write android ref App雖然沒有那麽的高大上,但是代碼的混淆是代表了程序員對App的責任心, 也是對App安全的一點點保證。今天我會將自己做Android混淆的過程和體會分享給大家,也避免大家少走彎路

IDEA 文檔註釋 亂碼 終極... 解決方案

RM nbsp odin src exe enc 最後一行 span png idea bin 目錄 下 phpstorm64.exe.vmoptions 最後一行添加 : -Dfile.encoding=UTF-8 IDEA 文檔註釋 亂

新手搭建 WordPress 網站終極解決方案 基於 Bitnami 堆棧快速搭建完美個人博客(Blog)

分享 成了 rdp 網上 特色 雲服務 nco BE tro 為了搭建一個自己的博客,對於沒有相關知識的我來說,真的時相當不容易,經過很長時間的摸索研究,總算是搭起了這個博客(Blog),那麽第一篇文章就是來記錄一下,經過反復的折騰後感覺最適合我自己的一個方法,文章包含很多

E: Sub-process /usr/bin/dpkg returned an error code (1)解決方案

命令 備份 ubun serial -a 正在 dir ria 3.0 最近在使用UBUNTU時安裝軟件包時出現了一個問題如下所示。 正在設置 ros-kinetic-rosserial-arduino (0.7.7-0xenial-20180316-183045-

ERROR 1010 (HY000): Error dropping database 解決方案

MySQL報錯: mysql> drop database test;ERROR 1010 (HY000): Error dropping database (can‘t rmdir ‘./test/‘, errno: 17) 解決方法: mysql> select @@datadir;+----

django 遠程數據庫mysql migrate失敗報error 1045之 解決方案

localhost 正在 tle 密碼修改 原因 就是 nbsp oot 遇到 Access denied for user ‘root‘@‘localhost‘ (using password: YES) ERROR 1045: Acce

雲原生:雲計算時代命題之終極解決方案

圖片 hit 讀者 最優 趨勢 打包成 容器化 公有雲 sca 雲原生:雲計算時代命題之終極解決方案 https://blog.csdn.net/broadview2006/article/details/80131068 2017年08月17日 14:35:05

jQuery AJAX中的$.ajax()方法請求成功卻始終進入error問題的解決方案及原因記錄

記錄 error 是我 jsb 應該 成了 blank 運行 可能 在這個示例中,當點擊“click me”按鈕後,jQuery會向tomcat請求a.txt文件,成功過後會彈出“success”警告框,失敗後會彈出“fail”警告框。 運行結果如下圖 當點擊按鈕時,

PHP 實現大資料(30w量級)表格匯出(匯出excel) 提高效率,減少記憶體消耗,終極解決方案

使用php做專案開發的同學,一定都會有過使用php進行excel表格匯出的經歷,當匯出少量資料還好,一旦資料量級達到5w、 10w、20w甚至30以上的時候就會面臨同樣的問題: 1、匯出時間變得很慢,少則1分鐘,多則好幾分鐘,資料量一旦上來,還可能面臨導不出來的困窘(這種匯出效率正常人都會受

解決ios軟鍵盤彈起遮蓋住底部輸入框的問題(終極解決方案!!!絕對好用)

html <div class="layout_flex">         <!-- 頭部 -->         <div class="header">header</

org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found終極解決方案

終於把問題找到了: 凡是出現這個錯誤,一定是路徑的問題。所以 1,檢查你的路徑寫對了沒有,對映檔案的路徑,配置檔案的路徑 2,如果還是出現錯誤,那一定是寫的方式不對~ 如圖 這是我的配置~一開始,我總是直接複製,全路徑,如圖 我一開始總是複製全路徑,然後往裡面放~所以,總出現找不到路

TEE+SE 是移動安全的終極解決方案嗎?

轉自:https://www.sohu.com/a/167500361_279109   隨著移動智慧裝置的快速普及,移動應用全方位地改變著網民的生活習慣,對人們的通訊、社交、娛樂和購物等各方面產生重要影響。近年來,各類移動應用的使用者規模和使用率均保持快速增長,電子商務類應用和娛樂類

Android使用gradle依賴管理、依賴衝突終極解決方案

Android使用gradle依賴管理、依賴衝突終極解決方案 在Android開發中,相信遇到關於版本依賴的問題的同學有不少。雖然Android Studio一般都會自動幫我們去重,但是有時候去重失敗了還是需要手動處理。在這裡總結下自己長期遇到的各類問題的解決方式。 統一版本管理

xml中1位元組的UTF-8序列的位元組1無效([字元編碼]Invalid byte 1 of 1-byte UTF-8 sequence終極解決方案

  xml中1位元組的UTF-8序列的位元組1無效([字元編碼]Invalid byte 1 of 1-byte UTF-8 sequence終極解決方案) 專案本地執行是ok的,但是釋出到線上伺服器就一直報錯,說什麼   Error

Resin宕機終極解決方案

                          Resin宕機終極解決方案   轉載:http://blog.sina.com.cn/s/blog_