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后即可正常启动项目

  • 相关阅读:
    Js原型对象理解
    Garbage In Garbage Out
    JournalNode的作用
    SecondaryNameNode 的作用
    Hive Map数据长尾问题
    Hive基本操作
    Hadoop中NameNode的工作机制
    技术架构分析与架构分析
    Sqoop报错Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
    项目管理PMP相关
  • 原文地址:https://www.cnblogs.com/small-panda/p/12858515.html
Copyright © 2011-2022 走看看