spring Boot (七) "Logback configuration error detected"

最近在搭建完工SpringBoot项目,且配置好logback之后,启动报错了,错误截图如下:
logback.error
文字报错内容截取关键部分如下:

at com.exam.api.boot.Bootstrap.main(Bootstrap.java:44)
Disconnected from the target VM, address: '127.0.0.1:50105', transport: 'socket'
Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@20:84 - no applicable action for [riollingPolicy], current ElementPath  is [[configuration][appender][riollingPolicy]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@21:30 - no applicable action for [fileNamePattern], current ElementPath  is [[configuration][appender][riollingPolicy][fileNamePattern]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@22:25 - no applicable action for [maxHistory], current ElementPath  is [[configuration][appender][riollingPolicy][maxHistory]]
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:162)

到底是为何呢?总是提示我 “Logback configuration error detected”,通过这个疑问则考虑了如下几点:

  • 】logback版本与SpringBoot冲突问题;
  • 】logback.xml配置问题;
  • 】maven依赖未成功的问题;

当然主要问题并非是自己想到的三个原因,最关键的是logback.xml里的关键字不知到什么时候多加了一个字母,哎,一言难尽啊。如图:
error
这也是部署到linux上导致info.log不显示的原因。
除此之外,还要注意最重要的一点,就是resources目录的问题:一般情况下,我们会弄成如下结构:
结构
这样就完全可以区分出测试环境,线上环境。这时候就要注意目录问题了,如下是常用的两种目录结构:
第一种:resources为Resources Root:
1
第一张图是在pom文件配置的resource路径
2
第二张图是默认设置resources为Resources Root
3
第三张install之后配置的目录环境,在dev下。
4
第四张图则是包路径的引入。
第二种:dev/prod为Resources Root:
11

12

13

14

为了避免自己的大意,平常搭建的过程中,切要细心哈。如果再引入不到的话,我们则可以看看output具体的路径是映射到了哪里,如下是我的电脑:
class

Logback configuration error detected问题而引发的两个问题就讲述到这里吧,有问题再联系。

猜你喜欢

转载自blog.csdn.net/huo065000/article/details/80678063