溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

spring boot日志報錯怎么辦

發(fā)布時間:2021-07-12 13:40:27 來源:億速云 閱讀:328 作者:小新 欄目:開發(fā)技術(shù)

這篇文章主要介紹了spring boot日志報錯怎么辦,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

記錄一次報錯解決方法:

No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]

org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to java.util.Map<java.lang.String, java.lang.String>
 at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:250)
 at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:226)
 at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210)
 at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:166)
 at org.springframework.boot.context.logging.LoggingApplicationListener.setLogLevels(LoggingApplicationListener.java:307)
 at org.springframework.boot.context.logging.LoggingApplicationListener.initializeFinalLoggingLevels(LoggingApplicationListener.java:290)
 at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:238)
 at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200)
 at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:173)
 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:127)
 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:361)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]
 at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321)
 at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194)
 at org.springframework.boot.context.properties.bind.BindConverter$CompositeConversionService.convert(BindConverter.java:162)
 at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:96)
 at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:88)
 at org.springframework.boot.context.properties.bind.MapBinder.bindAggregate(MapBinder.java:67)
 at org.springframework.boot.context.properties.bind.AggregateBinder.bind(AggregateBinder.java:58)
 at org.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$2(Binder.java:305)
 at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:441)
 at org.springframework.boot.context.properties.bind.Binder$Context.access$100(Binder.java:381)
 at org.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:304)
 at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:262)
 at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221)
 ... 18 common frames omitted

application.yml中的原配置如下:(spring boot版本2.0.4)

logging:
 path: ./logs/
 level: debug

報錯后,spring boot切換回1.5.9發(fā)現(xiàn)沒問題,因此去官網(wǎng)查找

官網(wǎng):https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-custom-log-levels

看到這部分

26.4 Log Levels

All the supported logging systems can have the logger levels set in the Spring Environment (for example, in application.properties) by using logging.level.<logger-name>=<level> where level is one of TRACE, DEBUG, INFO, WARN, ERROR, FATAL, or OFF. The root logger can be configured by using logging.level.root.

The following example shows potential logging settings in application.properties:

logging.level.root=WARN
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR

看完這部分,將yml改為如下:

logging:
 path: ./logs/
 level:
 root: debug

再次重啟,問題解決

感謝你能夠認真閱讀完這篇文章,希望小編分享的“spring boot日志報錯怎么辦”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識等著你來學習!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI