0

I have a logback.xml which has the following lines.

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="com.logback.someexternalLib.externalencoder"/>
    </appender>

this external encoder we dont have any access to change the code and takes care of sending logs to an external application. We want to format the logs before sending this to the external encoder

<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <pattern>lb %d{yyyy-MM-dd HH:mm:ss.SSS} ${CorrelationReplacePattern} A4D-%X{mdc.sessionId} %-5level %class{-1}.%M %L - %msg%n</pattern>
      </encoder>


      <encoder class="com.logback.someexternalLib.externalencoder" />
    </encoder>

The reason is we want the method name in each of our logs and also the correlation Id . How to make log line pass through 2 encoders. Can some one show us how to do this in logback.xml

hemanth
  • 113
  • 1
  • 7

0 Answers0