亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

springboot 使用logback啟動報警報錯的解決

 更新時間:2021年07月27日 11:17:48   作者:BUG記錄機  
這篇文章主要介紹了springboot 使用logback啟動報警報錯的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

springboot logback啟動報警報錯

報錯信息如下:

16:06:07,484 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
16:06:07,484 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
16:06:07,485 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/Users/Administrator/Desktop/***/***/target/classes/logback.xml]
16:06:07,638 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
16:06:07,646 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
16:06:07,653 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [consoleAppender]

先說解決方法:

把日志文件名稱改為-spring結(jié)尾就不報警了!!! logback-spring.xml

tips(springboot日志使用logback):

Spring Boot官方推薦優(yōu)先使用帶有-spring的文件名作為你的日志配置(如使用logback-spring.xml,而不是logback.xml),如果想自定義文件名,可以通過logging.config屬性指定自定義的名字:

logging.config=classpath:my-logging-config.xml

官方start包中已經(jīng)默認(rèn)集成了slf4j和logback不用導(dǎo)入任何日志依賴

推薦使用logback,性能優(yōu)于log4j

設(shè)置logback彩色日志

<property name="log.consolePattern" value="%highlight(%date{yyyy-MM-dd HH:mm:ss.SSS}) %boldYellow([%thread]) %highlight([%-5level])  %boldCyan([%replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''}]) %msg%n"/>

<!-- 控制臺設(shè)置,主要是上方pattern修改就可以,其他地方可以用不同pattern -->
<appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>${log.consolePattern}</pattern>  <!-- 控制臺日志輸出格式 -->
        <charset>utf8</charset>
    </encoder>
</appender>

springboot多環(huán)境開發(fā)日志

<!-- 測試環(huán)境+開發(fā)環(huán)境. 多個使用逗號隔開 -->
<springProfile name="test,dev">
 <logger name="工程包路徑" level="info" />
</springProfile>
<!-- 生產(chǎn)環(huán)境. -->
<springProfile name="prod">
 <logger name="工程包路徑" level="ERROR" />
</springProfile>

banner.txt

/***
 * _ooOoo_
 * o8888888o
 * 88" . "88
 * (| -_- |)
 *  O\ = /O
 * ___/`---'\____
 * .   ' \\| |// `.
 * / \\||| : |||// \
 * / _||||| -:- |||||- \
 * | | \\\ - /// | |
 * | \_| ''\---/'' | |
 * \ .-\__ `-` ___/-. /
 * ___`. .' /--.--\ `. . __
 * ."" '< `.___\_<|>_/___.' >'"".
 * | | : `- \`.;`\ _ /`;.`/ - ` : | |
 * \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 * `=---='
 *          .............................................
 *           佛曰:bug泛濫,我已癱瘓!
 */

springboot使用logback會遇到的坑

Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.apache.logging.slf4j.Log4jLoggerFactory loaded from file:/C:/Users/fyk/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.7/log4j-slf4j-impl-2.7.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.apache.logging.slf4j.Log4jLoggerFactory
	at org.springframework.util.Assert.instanceCheckFailed(Assert.java:389)
	at org.springframework.util.Assert.isInstanceOf(Assert.java:327)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:274)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:98)
	at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:230)
	at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:209)
	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.starting(EventPublishingRunListener.java:69)
	at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:292)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
	at com.light.SpringbootApplication.main(SpringbootApplication.java:32)
	... 5 more

在spring boot中導(dǎo)入logback jar包會與spring-boot-starter-web沖突,應(yīng)該是springboot中已經(jīng)包含了這個包,

   <dependency>
   <groupId>ch.qos.logback</groupId>
   <artifactId>logback-classic</artifactId>
   <version>1.2.3</version>
  </dependency>

去掉這個導(dǎo)入就好了!

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Java String中的split方法使用總結(jié)

    Java String中的split方法使用總結(jié)

    這篇文章主要介紹了Java String中的split方法使用總結(jié),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • SpringBoot實現(xiàn)多端口監(jiān)聽的代碼示例

    SpringBoot實現(xiàn)多端口監(jiān)聽的代碼示例

    當(dāng)你需要在同一個Spring Boot應(yīng)用中,通過不同的端口來提供不同的服務(wù)或功能時,就需要實現(xiàn)多端口監(jiān)聽,所以本文給大家介紹了SpringBoot實現(xiàn)多端口監(jiān)聽的方法示例,并有相關(guān)的代碼示例供大家參考,需要的朋友可以參考下
    2024-09-09
  • Spring Cloud Gateway去掉url前綴

    Spring Cloud Gateway去掉url前綴

    這篇文章主要介紹了Spring Cloud Gateway去掉url前綴的操作,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-07-07
  • Jenkins使用Gradle編譯Android項目詳解

    Jenkins使用Gradle編譯Android項目詳解

    這篇文章主要介紹了Jenkins使用Gradle編譯Android項目詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-07-07
  • IDEA新建javaWeb以及Servlet簡單實現(xiàn)小結(jié)

    IDEA新建javaWeb以及Servlet簡單實現(xiàn)小結(jié)

    這篇文章主要介紹了IDEA新建javaWeb以及Servlet簡單實現(xiàn)小結(jié),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-11-11
  • java 重載(overload)與重寫(override)詳解及實例

    java 重載(overload)與重寫(override)詳解及實例

    這篇文章主要介紹了java 重載(overload)與重寫(override)詳解及實例的相關(guān)資料,并附實例代碼,需要的朋友可以參考下
    2016-10-10
  • idea中maven項目模塊變成灰色原因及解決方案

    idea中maven項目模塊變成灰色原因及解決方案

    這篇文章主要介紹了idea中maven項目模塊變成灰色原因及解決方案,文中通過圖文結(jié)合的方式給大家講解的非常詳細(xì),對大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2024-03-03
  • Spring中的@ModelAttribute模型屬性綁定詳解

    Spring中的@ModelAttribute模型屬性綁定詳解

    這篇文章主要介紹了Spring中的@ModelAttribute模型屬性綁定詳解,@ModelAttribute用于將方法參數(shù)或返回值綁定到Model屬性上,并公開給Web視圖,支持使用@RequestMapping注釋的Controller類,需要的朋友可以參考下
    2024-02-02
  • SpringBoot+SpringSecurity 不攔截靜態(tài)資源的實現(xiàn)

    SpringBoot+SpringSecurity 不攔截靜態(tài)資源的實現(xiàn)

    這篇文章主要介紹了SpringBoot+SpringSecurity 不攔截靜態(tài)資源的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • 消息中間件詳解以及比較選擇

    消息中間件詳解以及比較選擇

    這篇文章主要介紹了消息中間件詳解以及比較選擇,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08

最新評論