SpringBoot2 log报错:Failed to bind properties under 'logging.level' to...

谁践踏了优雅 2023-06-24 15:27 107阅读 0赞

springboot2 启动时 log 配置报错,版本 boot 2.2.1。

Failed to bind properties under ‘logging.level’ to java.util.Map…

  1. org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to java.util.Map<java.lang.String, org.springframework.boot.logging.LogLevel>
  2. at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:364) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  3. at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:324) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  4. at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:308) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  5. at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:238) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  6. at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:212) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]

查看官网资料,得到新用法如下,和1.4老版本的不一样。logging.level后面需要指定对应的 “logger-name”,可以默认设置为root。

官方文档:https://docs.spring.io/spring-boot/docs/2.1.1.RELEASE/reference/htmlsingle/#boot-features-custom-log-levelswatermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3NoaXBmZWlfY3Nkbg_size_16_color_FFFFFF_t_70

修改log配置如下,

  1. logging:
  2. level:
  3. root: info # 指定日志基本
  4. file:
  5. path: E:\logs\zm-sms # 指定日志输出的文件路径

重新启动成功。

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3NoaXBmZWlfY3Nkbg_size_16_color_FFFFFF_t_70 1

发表评论

表情:
评论列表 (有 0 条评论,107人围观)

还没有评论,来说两句吧...

相关阅读