zoukankan      html  css  js  c++  java
  • springboot+logback进行日志输出时报java.lang.IllegalStateException: Logback configuration error detected

    Logging system failed to initialize using configuration from 'classpath:logback.xml'
    java.lang.IllegalStateException: Logback configuration error detected: 
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@89:31 - no applicable action for [springProfile], current ElementPath  is [[configuration][springProfile]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@90:28 - no applicable action for [root], current ElementPath  is [[configuration][springProfile][root]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@91:41 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@92:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@93:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169)
        at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)
        at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:57)
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:118)
        at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:318)
        at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:288)
        at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
        at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
        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:76)
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
        at com.example.demo.DemoApplication.main(DemoApplication.java:16)
    [2020-05-09 16:07:36.478] [main] ERROR o.s.boot.SpringApplication : Application run failed
    java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected: 
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@89:31 - no applicable action for [springProfile], current ElementPath  is [[configuration][springProfile]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@90:28 - no applicable action for [root], current ElementPath  is [[configuration][springProfile][root]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@91:41 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@92:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@93:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
        at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:324)
        at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:288)
        at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
        at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
        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:76)
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
        at com.example.demo.DemoApplication.main(DemoApplication.java:16)
    Caused by: java.lang.IllegalStateException: Logback configuration error detected: 
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@89:31 - no applicable action for [springProfile], current ElementPath  is [[configuration][springProfile]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@90:28 - no applicable action for [root], current ElementPath  is [[configuration][springProfile][root]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@91:41 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@92:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@93:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169)
        at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)
        at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:57)
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:118)
        at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:318)
        ... 14 common frames omitted
    Exception in thread "main" java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected: 
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@89:31 - no applicable action for [springProfile], current ElementPath  is [[configuration][springProfile]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@90:28 - no applicable action for [root], current ElementPath  is [[configuration][springProfile][root]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@91:41 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@92:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@93:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
        at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:324)
        at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:288)
        at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
        at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
        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:76)
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
        at com.example.demo.DemoApplication.main(DemoApplication.java:16)
    Caused by: java.lang.IllegalStateException: Logback configuration error detected: 
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@89:31 - no applicable action for [springProfile], current ElementPath  is [[configuration][springProfile]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@90:28 - no applicable action for [root], current ElementPath  is [[configuration][springProfile][root]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@91:41 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@92:43 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
    ERROR in ch.qos.logback.core.joran.spi.Interpreter@93:44 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169)
        at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)
        at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:57)
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:118)
        at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:318)
        ... 14 more
    Disconnected from the target VM, address: '127.0.0.1:61593', transport: 'socket'
    
    Process finished with exit code 1
    View Code

    springboot整合logback时遇到上面报错

    直接在springboot官方文档 中找到错误的原因:

    文档中将的很清楚,在springboot中包含了很多logback的扩展可以支持我们进行一些更高级的配置,比如逻辑判断
    如果使用logback.xml的话会使logback的配置加载的过早,无法使用扩展配置,需要修改logback的配置文件命名为logback-spring.xml才能使用
    如果直接使用logback.xml配置方式的话会导致current ElementPath is [[configuration][springProfile]]等错误
    检查logback的命名发现项目中我名字为logback.mxl修改成logback-spring.xml后即可正常启动项目

  • 相关阅读:
    IEnumerable、IEnumerator接口(如何增加迭代器功能)
    IConvertible接口
    IComparable和IComparer接口
    c#-泛型、协变、逆变
    MVC-HtmlHelper扩展
    .Net反射-TypeDescriptor
    MVC Core 使用TagHelper扩展几个插件
    js日志组件封装
    js预解析
    js代码优化
  • 原文地址:https://www.cnblogs.com/small-panda/p/12858515.html
Copyright © 2011-2022 走看看