title: Print a specific header in using logback in spring boot
body: <p>I am using spring-boot and using logback to generate the logs. Now I want to log a specific header in every log.</p>
  
  <p>How can i achieve that.</p>
  
  <p>My logback file is </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
    &lt;springProperty name="appName" source="spring.application.name" defaultValue="apigateway" /&gt;
      &lt;property name="LOG_PATH" value="${LOG_PATH}" /&gt;
      &lt;!-- Console logging --&gt;
      &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;
                  [%d{YYYY-MM-dd HH:mm:ss.SSS}] [%X{X-B3-CONVID:-}] [%X{X-B3-TraceId:-}] [%X{X-B3-SpanId:-}] [${HOSTNAME}] [%level] [${appName}] [%logger{36}.%M] - %msg %n
              &lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;appender name="APPLICATIONLOG" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
          &lt;append&gt;true&lt;/append&gt;
          &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
              &lt;fileNamePattern&gt;${LOG_PATH}/applogs/application.%d{yyyy-MM-dd}.log&lt;/fileNamePattern&gt;
              &lt;maxHistory&gt;60&lt;/maxHistory&gt;
              &lt;totalSizeCap&gt;20GB&lt;/totalSizeCap&gt;
          &lt;/rollingPolicy&gt;
  
          &lt;encoder&gt;
              &lt;Pattern&gt;
                  [%d{YYYY-MM-dd HH:mm:ss.SSS}] [%X{X-B3-CONVID:-}] [%X{X-B3-TraceId:-}] [%X{X-B3-SpanId:-}] [${HOSTNAME}] [%level] [${appName}] [%logger{36}.%M] - %msg %n
              &lt;/Pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
  
      &lt;!-- set logger level: e.g. info, trace, debug, error --&gt;
      &lt;root level="info"&gt;
          &lt;appender-ref ref="STDOUT" /&gt;
          &lt;appender-ref ref="APPLICATIONLOG" /&gt;
      &lt;/root&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Apart from this I have not done anything to confgure the logs.
  Just added the dependency for slf4j and then added the logback spring file.</p>
  
  <p>Any help is appreciated</p>