Logback新版本报no applicable action for [Encoding]问题

logback.xml配置文件如下:



<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
    
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
            pattern>
        encoder>
    appender>
       
    <appender name="FILE"  class="ch.qos.logback.core.rolling.RollingFileAppender">   
        <file>./logs/qz-liuxuejia.logfile> 
        <Encoding>UTF-8Encoding>   
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            
            <FileNamePattern>./logs/qz-liuxuejia.%d{yyyy-MM-dd}.logFileNamePattern>   
            <MaxHistory>30MaxHistory>
        rollingPolicy>   
        <layout class="ch.qos.logback.classic.PatternLayout">  
             
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n   
            pattern>   
       layout> 
        
       
    appender> 

    
    
    
    
    
    <logger name="jdbc.sqltiming" level="DEBUG"/>
    <logger name="com.ibatis" level="DEBUG" />
    <logger name="com.ibatis.common.jdbc.SimpleDataSource" level="DEBUG" />
    <logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG" />
    <logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="DEBUG" />
    <logger name="java.sql.Connection" level="DEBUG" />
    <logger name="java.sql.Statement" level="DEBUG" />
    <logger name="java.sql.PreparedStatement" level="DEBUG" />
    
    <root level="DEBUG">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="FILE"/>
    root>
configuration>  

启动项目报错:

*Logging system failed to initialize using configuration from 'classpath:logback-spring.xml'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@16:19 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]] at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:152)

从上面的错误可以看出no applicable action for [Encoding]是因为Encoding标签是不可用的.因为是从老项目拿的文件过来,之前用的logback也比较老,在最新版本1.1.7中这一个配置已经不能用了,所以只要把UTF-8这个配置去掉就可以解决的上面的问题。

你可能感兴趣的:(logback,springboot,logback)