基于spring boot 日志(logback)报错的解决方式

作者:懒惰的小蜗牛 时间:2022-05-12 08:13:46 

记录一次报错解决方法:

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发现没问题,因此去官网查找

官网: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

再次重启,问题解决

来源:https://blog.csdn.net/qq_41070393/article/details/82179542

标签:spring,boot,日志,logback
0
投稿

猜你喜欢

  • fso怎样判断一个盘上是否有文件

    2007-09-26 12:35:00
  • Python对象与引用的介绍

    2023-04-30 12:51:59
  • 如何用python抓取B站数据

    2023-07-19 20:02:55
  • python+opencv实现堆叠图片

    2023-07-19 21:22:45
  • 网页栅格系统研究(4):技术实现

    2008-11-06 11:44:00
  • 使用标准的表单字段名

    2008-06-30 14:14:00
  • 原生JS封装_new函数实现new关键字的功能

    2023-09-05 00:44:27
  • pytorch fine-tune 预训练的模型操作

    2023-05-02 01:05:25
  • python numpy存取文件的方式

    2021-04-15 18:31:56
  • Access秘密技巧和陷阱

    2008-04-12 14:55:00
  • SQL 统计一个数据库中所有表记录的数量

    2012-01-29 18:21:36
  • 交互设计实用指南系列(8)—深广度平衡

    2010-02-01 12:59:00
  • Python 多线程超详细到位总结

    2021-02-17 04:10:58
  • Python多线程爬取豆瓣影评API接口

    2023-07-28 05:33:48
  • PHP simplexml_import_dom()函数讲解

    2023-06-09 19:18:30
  • Python json模块与jsonpath模块区别详解

    2023-09-17 18:07:26
  • css网页下拉菜单制作方法(3):样式修饰

    2007-02-03 11:39:00
  • Python入门教程(十三)Python元组

    2023-10-28 08:42:24
  • python使用tkinter库实现五子棋游戏

    2021-07-25 20:35:17
  • 不安全的js写法

    2009-09-16 14:26:00
  • asp之家 网络编程 m.aspxhome.com