logback icon indicating copy to clipboard operation
logback copied to clipboard

Introduce AsyncAppender for logback-access: LOGBACK-827

Open kpavlov opened this issue 11 years ago • 5 comments

Introduced ch.qos.logback.access.AsyncAppender which accepts IAccessEvents. Standard AsyncAppender from logback-classic does not support IAccessEvents and fails with exception:

18:31:29,255 |-ERROR in ch.qos.logback.classic.AsyncAppender[access.file.async] - Appender [access.file.async] failed to append. java.lang.ClassCastException: ch.qos.logback.access.spi.AccessEvent cannot be cast to ch.qos.logback.classic.spi.ILoggingEvent
    at java.lang.ClassCastException: ch.qos.logback.access.spi.AccessEvent cannot be cast to ch.qos.logback.classic.spi.ILoggingEvent
    at  at ch.qos.logback.classic.AsyncAppender.preprocess(AsyncAppender.java:28)

Proposed fix for http://jira.qos.ch/browse/LOGBACK-827

Example logback-access.xml:

<?xml version='1.0' encoding='utf-8'?>
<configuration>

    <!-- always a good activate OnConsoleStatusListener -->
    <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener"/>

    <!-- See for reference: http://logback.qos.ch/access.html#configuration -->
    <appender name="access.file" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${catalina.base}/logs/access.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- rollover daily -->
            <fileNamePattern>${catalina.base}/logs/access.%d{yyyy-MM-dd}.%i.log.tar.gz</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <!-- or whenever the file size reaches 100MB -->
                <maxFileSize>100KB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <encoder>
            <pattern>combined</pattern>
        </encoder>
    </appender>

    <appender name="access.file.async" class="ch.qos.logback.access.AsyncAppender">
        <appender-ref ref="access.file"/>
    </appender>

    <appender-ref ref="access.file.async"/>
</configuration>

kpavlov avatar Apr 03 '14 21:04 kpavlov

commit cb5d423 changes a bunch of lines in DummyRequest.java making it hard to see what actually changed. Please use the same formatting as the rest of the code, in particular indent size of 2. As such, I can't merge this pull request for the moment.

Please also read and follow the steps outlines in the contribution guidelines

ceki avatar Apr 04 '14 17:04 ceki

Hi,

When can we expect this feature? Will this be merged?

bharathrajbk avatar Jul 09 '18 14:07 bharathrajbk

Hey people any news about this feature :)

iagoquirino avatar Feb 20 '19 09:02 iagoquirino

Hi there, we are seeing this issue now, any updates on the fix?

AlexJHayward avatar Jul 09 '19 08:07 AlexJHayward

Yo. Would love to use AsyncAppender for my access events. Any news?

fschmager avatar Jul 26 '19 14:07 fschmager