Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1506

Use %replace to operate on %exception in a configuration file, the exception is added to the end

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: logback-classic
    • Labels:
    • Environment:

      jdk 1.8

      win10

      Springboot Finchley.RELEASE

      Description

      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

      <?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>

        Attachments

          Activity

            People

            Assignee:
            logback-dev Logback dev list
            Reporter:
            YuSongyi YuSongyi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: