<configuration>
  <include resource="org/springframework/boot/logging/logback/defaults.xml"/>

  <conversionRule conversionWord="clr" class="org.springframework.boot.logging.logback.ColorConverter"/>
  <conversionRule conversionWord="wex" class="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
  <conversionRule conversionWord="wEx" class="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>

  <springProperty scope="context" name="LOGGING_PARENT" source="logging.parent"/>
  <springProperty scope="context" name="APP_NAME" source="spring.application.name"/>

  <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %clr(%5p) %clr([${HOSTNAME}]){yellow} %clr([%t]){magenta} %clr(%logger{40}){cyan}: %m%n%wEx
      </pattern>
    </encoder>
  </appender>

  <appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${LOGGING_PARENT:-.}/${APP_NAME:-run}.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>${LOGGING_PARENT:-.}/archive/${APP_NAME:-run}-%d{yyyy-MM-dd}.gz</fileNamePattern>
      <MaxHistory>7</MaxHistory>
      <totalSizeCap>5GB</totalSizeCap>
    </rollingPolicy>
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [${HOSTNAME}] [%t] %logger: %m%n%wEx</pattern>
    </encoder>
  </appender>

  <logger name="com.zaxxer.hikari" level="ERROR"/>
  <!--<logger name="org.hibernate.SQL" level="DEBUG"/>-->

  <root level="INFO">
    <appender-ref ref="Console"/>
    <appender-ref ref="RollingFile"/>
  </root>
</configuration>