<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="true" scanPeriod="30 seconds">

    <springProperty name="LOG_LEVEL" source="sys.log.level" scope="context" defaultValue="INFO"/>

    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
    <property name="LOG_PATTERN"
              value="%d{yyyy-MM-dd HH:mm:ss.SSS} | %clr(%-5level) | %clr(%logger{39}:%L){cyan} | %clr(%thread %X{TRACE_ID}){blue} | %msg%n"/>

    <appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${LOG_PATTERN}</pattern>
            <!--<charset>UTF-8</charset>-->
        </encoder>
    </appender>

    <appender name="FILE_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <encoder>
            <pattern>${LOG_PATTERN}</pattern>
            <!--<charset>UTF-8</charset>-->
        </encoder>

        <file>logs/examcloud-tool.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>logs/examcloud-tool-%d{yyyyMMdd}-%i.log</fileNamePattern>
            <maxHistory>30</maxHistory>
            <maxFileSize>100MB</maxFileSize>
            <totalSizeCap>10GB</totalSizeCap>
        </rollingPolicy>
    </appender>

    <logger name="org.springframework" level="WARN"/>
    <logger name="org.hibernate" level="WARN"/>
    <logger name="org.apache" level="WARN"/>
    <logger name="com.zaxxer.hikari" level="WARN"/>
    <logger name="org.quartz" level="WARN"/>

    <!--
    <Logger name="org.hibernate.SQL" level="DEBUG"/>
    <Logger name="org.hibernate.engine.transaction" level="DEBUG"/>
    <Logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>
    <logger name="org.springframework.jdbc.core.JdbcTemplate" level="DEBUG"/>
    -->

    <Logger name="cn.com.qmth" level="${LOG_LEVEL}" additivity="false">
        <appender-ref ref="CONSOLE_APPENDER"/>
        <appender-ref ref="FILE_APPENDER"/>
    </Logger>

    <root level="${LOG_LEVEL}">
        <appender-ref ref="CONSOLE_APPENDER"/>
        <appender-ref ref="FILE_APPENDER"/>
    </root>

</configuration>
