Logback with LoggingEventCompositeJsonEncoder do not log events when throwable object is added

Viewed 3675

I am working with Spring boot/Spring cloud stream project

I use Logback for logging with ConsoleAppender and LoggingEventCompositeJsonEncoder as encoder

when I am trying to log an error, in case just a message or message with structured arguments is passed it work

but when I add any type of exception/throwable nothing is logged at all

this are examples that will be logged:

appLogger.error("some error message");
appLogger.error("some error message", StructuredArguments.keyValue("param1", "value1"));

this is example that will not be logged:

appLogger.error("some error message", e);  // e is some none null of Exception type object

this is my logback xml configuration:

<appender name="JSON_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
        <providers>
            <contextName>
                <fieldName>app</fieldName>
            </contextName>
            <timestamp>
                <fieldName>ts</fieldName>
                <timeZone>UTC</timeZone>
            </timestamp>
            <loggerName>
                <fieldName>logger</fieldName>
            </loggerName>
            <logLevel>
                <fieldName>level</fieldName>
            </logLevel>
            <callerData>
                <classFieldName>class</classFieldName>
                <methodFieldName>method</methodFieldName>
                <lineFieldName>line</lineFieldName>
                <fileFieldName>file</fileFieldName>
            </callerData>
            <threadName>
                <fieldName>thread</fieldName>
            </threadName>
            <mdc />
            <arguments>
                <includeNonStructuredArguments>true</includeNonStructuredArguments>
            </arguments>
            <stackTrace>
                <fieldName>stack</fieldName>
            </stackTrace>
            <message>
                <fieldName>msg</fieldName>
            </message>
        </providers>
    </encoder>
</appender>

<logger name="application1" additivity="false">
    <appender-ref ref="JSON_CONSOLE" />
</logger>

What am I missing here? Why the logger ignore or fail on errors with Exception, according to docs if Exception is the last param it should be parsed using ExtendedThrowableProxyConverter

0 Answers
Related