基于spring boot 日志(logback)报错的解决方式
记录一次报错解决方法:
Noconverterfoundcapableofconvertingfromtype[java.lang.String]totype[java.util.Map
]
org.springframework.boot.context.properties.bind.BindException:Failedtobindpropertiesunder'logging.level'tojava.util.Mapatorg.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:250) atorg.springframework.boot.context.properties.bind.Binder.bind(Binder.java:226) atorg.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210) atorg.springframework.boot.context.properties.bind.Binder.bind(Binder.java:166) atorg.springframework.boot.context.logging.LoggingApplicationListener.setLogLevels(LoggingApplicationListener.java:307) atorg.springframework.boot.context.logging.LoggingApplicationListener.initializeFinalLoggingLevels(LoggingApplicationListener.java:290) atorg.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:238) atorg.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200) atorg.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:173) atorg.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) atorg.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) atorg.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) atorg.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) atorg.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) atorg.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) atorg.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:361) atorg.springframework.boot.SpringApplication.run(SpringApplication.java:320) atorg.springframework.boot.SpringApplication.run(SpringApplication.java:1258) atorg.springframework.boot.SpringApplication.run(SpringApplication.java:1246) Causedby:org.springframework.core.convert.ConverterNotFoundException:Noconverterfoundcapableofconvertingfromtype[java.lang.String]totype[java.util.Map ] atorg.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) atorg.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) atorg.springframework.boot.context.properties.bind.BindConverter$CompositeConversionService.convert(BindConverter.java:162) atorg.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:96) atorg.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:88) atorg.springframework.boot.context.properties.bind.MapBinder.bindAggregate(MapBinder.java:67) atorg.springframework.boot.context.properties.bind.AggregateBinder.bind(AggregateBinder.java:58) atorg.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$2(Binder.java:305) atorg.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:441) atorg.springframework.boot.context.properties.bind.Binder$Context.access$100(Binder.java:381) atorg.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:304) atorg.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:262) atorg.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221) ...18commonframesomitted
application.yml中的原配置如下:(springboot版本2.0.4)
logging: path:./logs/ level:debug
报错后,springboot切换回1.5.9发现没问题,因此去官网查找
官网:https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-custom-log-levels
看到这部分
26.4LogLevels
AllthesupportedloggingsystemscanhavetheloggerlevelssetintheSpringEnvironment(forexample,inapplication.properties)byusinglogging.level.
= wherelevelisoneofTRACE,DEBUG,INFO,WARN,ERROR,FATAL,orOFF.Therootloggercanbeconfiguredbyusinglogging.level.root. Thefollowingexampleshowspotentialloggingsettingsinapplication.properties:
logging.level.root=WARN logging.level.org.springframework.web=DEBUG logging.level.org.hibernate=ERROR
看完这部分,将yml改为如下:
logging: path:./logs/ level: root:debug
再次重启,问题解决
以上这篇基于springboot日志(logback)报错的解决方式就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。