Search code examples
androidlogbackasyncappender

Logback Android ERROR: no applicable action for [queuesize] [encoder][immediateFlush]


What does "no applicable action for [*]" mean?

I: 15:24:17,169 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@24:20 - no applicable action for [queuesize], current ElementPath  is [[configuration][appender][queuesize]]
I: 15:24:17,176 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@25:18 - no applicable action for [encoder], current ElementPath  is [[configuration][appender][encoder]]
I: 15:24:17,188 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@26:29 - no applicable action for [immediateFlush], current ElementPath  is [[configuration][appender][encoder][immediateFlush]]

Does it mean that the way I've configured it is wrong and that the config line is ignored?? What am I doing wrong?

logback.xml :

<configuration debug="true">
<shutdownHook/>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${DATA_DIR}/logs/jdtest.log</file>

    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>${DATA_DIR}/logs/jdtest.%i.log.zip</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>3</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>100KB</maxFileSize>
    </triggeringPolicy>

    <encoder>
        <pattern>%d{yy.MM.dd HH:mm:ss.SSS}:\t%logger:\t%msg%n</pattern>
      <outputPatternAsHeader>true</outputPatternAsHeader>
    </encoder>
</appender>

<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
    <queuesize>1000</queuesize>
    <encoder>
        <immediateFlush>false</immediateFlush>
    </encoder>
    <appender-ref ref="FILE" />
</appender>


<root level="ALL">
    <appender-ref ref="ASYNC" />
</root>
</configuration>

gradle:

dependencies { 
    implementation 'org.slf4j:slf4j-api:1.7.30'
    implementation 'com.github.tony19:logback-android:2.0.0'
}

Solution

  • AsyncAppender has no encoder properties.And AsyncAppender has queueSize properties rather than queuesize .If you want to use shutdownHook, designated used class

    <configuration debug="true">
    <!--    <shutdownHook/>-->
    
        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>${DATA_DIR}/logs/jdtest.log</file>
    
            <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
                <fileNamePattern>${DATA_DIR}/logs/jdtest.%i.log.zip</fileNamePattern>
                <minIndex>1</minIndex>
                <maxIndex>3</maxIndex>
            </rollingPolicy>
    
            <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
                <maxFileSize>100KB</maxFileSize>
            </triggeringPolicy>
    
            <encoder>
                <pattern>%d{yy.MM.dd HH:mm:ss.SSS}:\t%logger:\t%msg%n</pattern>
                <outputPatternAsHeader>true</outputPatternAsHeader>
            </encoder>
        </appender>
    
        <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
            <queueSize>1000</queueSize>
    <!--        <encoder>-->
    <!--            <immediateFlush>false</immediateFlush>-->
    <!--        </encoder>-->
            <appender-ref ref="FILE" />
        </appender>
    
    
        <root level="ALL">
            <appender-ref ref="ASYNC" />
        </root>
    </configuration>