kind: ConfigMap
apiVersion: v1
metadata:
  name: logback-access-xml
data:
  logback-access.xml: |-
    <configuration debug="true">
      <!-- always a good activate OnConsoleStatusListener -->
      <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />  

      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!--
          Don't log the probs request from OpenShift
        -->
        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
          <evaluator name="DontLogHealth">
            <expression>
              if(event.getRequestURI().contains("/health"))
                return true;
              return false;
            </expression>
          </evaluator>
          <onMatch>DENY</onMatch>
        </filter>

        <encoder class="net.logstash.logback.encoder.AccessEventCompositeJsonEncoder">
          <providers>
            <pattern>
              <pattern>
                {
                "timestamp": "%t",
                "remote_ip": "%reqAttribute{org.apache.tomcat.remoteAddr}",
                "status_code": "#asLong{%s}",
                "user": "%u",
                "elapsed_time": "#asLong{%D}",
                "bytesSent": "#asLong{%b}",
                "requestURL": "%r",
                "referer": "%i{Referer}",
                "user_agent": "%i{User-Agent}",
                "session": "%requestCookie{JSESSIONID}",
                "fullRequest": "%fullRequest"
                }
              </pattern>
            </pattern>
          </providers>
        </encoder>
        <encoder>
          <!-- 
            fullRequest prints all headers from the request. In case you don't need this info
            can you remove %fullRequest from pattern.
            elapsedTime The time taken to serve the request, in milliseconds.
            All pattern are documented in the doc.
            http://logback.qos.ch/manual/layouts.html#AccessPatternLayout
          -->
          <pattern>%fullRequest%reqAttribute{org.apache.tomcat.remoteAddr} %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}" %elapsedTime</pattern>
        </encoder>
      </appender>

      <appender-ref ref="STDOUT" />
    </configuration>

