Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logback AsyncAppender does not log context details #1262

Open
shamoh opened this issue Feb 19, 2023 Discussed in #1260 · 0 comments
Open

Logback AsyncAppender does not log context details #1262

shamoh opened this issue Feb 19, 2023 Discussed in #1260 · 0 comments

Comments

@shamoh
Copy link

shamoh commented Feb 19, 2023

Discussed in #1260

Originally posted by shamoh February 12, 2023
I use TraceIDConverter to log request ID or ContextEntryConverter for additional information. But it does not work in case of AsyncAppender. Target appender is ConsoleAppender.

My configuration is:

<configuration scan="false" debug="false">
    <conversionRule conversionWord="traceId"
                    converterClass="kamon.instrumentation.logback.tools.TraceIDConverter"/>
    <conversionRule conversionWord="contextEntry"
                    converterClass="kamon.instrumentation.logback.tools.ContextEntryConverter"/>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
            <providers>
                <timestamp/>
                <pattern>
                    <omitEmptyFields>true</omitEmptyFields>
                    <pattern>
                        {
                            "request-id": "%traceId",
                            "entry-component": "%contextEntry{entryComponent}",
                        }
                    </pattern>
                </pattern>
            </providers>
        </encoder>
    </appender>

    <appender name="ASYNC-STDOUT" class="ch.qos.logback.classic.AsyncAppender">
        <queueSize>8192</queueSize>
        <neverBlock>true</neverBlock>
        <discardingThreshold>25</discardingThreshold>

        <appender-ref ref="STDOUT"/>
    </appender>

    <logger name="com.example.my" level="INFO"/>

    <root level="INFO">
        <appender-ref ref="ASYNC-STDOUT"/> <!-- does NOT work -->
        <!-- OR -->
        <appender-ref ref="STDOUT"/>       <!-- it WORKS -->
    </root>
</configuration>

If I use STDOUT appender it correctly logs request-id and entry-component. While in case of ASYNC-STDOUT appender it does not log entry-component and request-id is undefined.

Documentation (https://kamon.io/docs/latest/instrumentation/logback/) says AsyncAppender is supported. Do I use wrong combination of appender and encoder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant