[logback-dev] [JIRA] (LOGBACK-1506) Use %replace to operate on %exception in a configuration file, the exception is added to the end

QOS.CH (JIRA) noreply-jira at qos.ch
Sat Feb 15 18:13:00 CET 2020


YuSongyi created LOGBACK-1506:
---------------------------------

             Summary: Use %replace to operate on %exception in a configuration file, the exception is added to the end
                 Key: LOGBACK-1506
                 URL: https://jira.qos.ch/browse/LOGBACK-1506
             Project: logback
          Issue Type: Bug
          Components: logback-classic
    Affects Versions: 1.2.3
         Environment: jdk 1.8

win10

Springboot Finchley.RELEASE
            Reporter: YuSongyi
            Assignee: Logback dev list
         Attachments: TIM截图20200215235542-2-1024x778.jpg, TIM截图20200215235542.jpg

It will add the contents of the exception to the end of the formatted log. As shown below, according to the format defined above, its content should end at the arrow.

 

logback.xml
{code:java}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<springProperty scope="context" name="springAppName" source="spring.application.name" />
<property name="LOG_FILE" value="${BUILD_FOLDER:-build}/${springAppName}" />

<appender name="kafkaAppender"
class="com.github.danielwegener.logback.kafka.KafkaAppender">
<encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>
{
"severity": "%level",
"service": "${springAppName:-}",
"trace": "%X{X-B3-TraceId:-}",
"span": "%X{X-B3-SpanId:-}",
"exportable": "%X{X-Span-Export:-}",
"stack_trace": "%replace(%exception{10}){'\n',''}",
"pid": "${PID:-}",
"thread": "%thread",
"class": "%logger{40}",
"rest": "%message"
}
</pattern>
</encoder>
<topic>applog</topic>
<keyingStrategy class="com.github.danielwegener.logback.kafka.keying.NoKeyKeyingStrategy" />
<deliveryStrategy
class="com.github.danielwegener.logback.kafka.delivery.AsynchronousDeliveryStrategy" />

<!-- bootstrap.servers is the only mandatory producerConfig -->
<producerConfig>bootstrap.servers=******** </producerConfig>
</appender>


<root level="INFO">
<appender-ref ref="kafkaAppender" />
</root>

</configuration>{code}



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the logback-dev mailing list