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

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

Failed to bind properties under 'logging.level' to java.util.Map...

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>
	at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:364) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:324) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:308) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:238) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	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-levels

修改log配置如下,

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

重新启动成功。

发布了125 篇原创文章 · 获赞 116 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/shipfei_csdn/article/details/103677152