<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <springProperty scope="context" name="appName" source="spring.application.name" defaultValue="ordinis-read-api"/>
  <springProperty scope="context" name="environment" source="ENVIRONMENT" defaultValue="dev"/>

  <appender name="STDOUT_JSON" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="net.logstash.logback.encoder.LogstashEncoder">
      <includeMdcKeyName>trace_id</includeMdcKeyName>
      <includeMdcKeyName>span_id</includeMdcKeyName>
      <includeMdcKeyName>scope</includeMdcKeyName>
      <includeMdcKeyName>dictionary</includeMdcKeyName>
      <includeMdcKeyName>locale</includeMdcKeyName>
      <includeMdcKeyName>request_id</includeMdcKeyName>
      <includeMdcKeyName>user_id</includeMdcKeyName>
      <customFields>{"service":"${appName}","environment":"${environment}"}</customFields>
    </encoder>
  </appender>

  <appender name="STDOUT_HUMAN" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <springProfile name="dev">
    <root level="INFO">
      <appender-ref ref="STDOUT_HUMAN"/>
    </root>
    <logger name="cloud.nstart.terravault.ordinis" level="DEBUG"/>
  </springProfile>

  <springProfile name="!dev">
    <root level="INFO">
      <appender-ref ref="STDOUT_JSON"/>
    </root>
    <logger name="cloud.nstart.terravault.ordinis" level="DEBUG"/>
  </springProfile>
</configuration>
