<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>

    <!-- 测试环境+开发环境. 多个使用逗号隔开. -->
    <springProfile name="test,dev">
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <layout class="ch.qos.logback.classic.PatternLayout">
                <pattern>%d{ISO8601} [%thread] [%-5level] %logger - %msg%n</pattern>
            </layout>
        </appender>
        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>logs/rule-engine.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <fileNamePattern>logs/asset-distribution.log.%d{yyyy-MM-dd}</fileNamePattern>
                <maxHistory>7</maxHistory>
            </rollingPolicy>
            <layout class="ch.qos.logback.classic.PatternLayout">
                <pattern>%d{ISO8601} [%thread] [%-5level] %logger - %msg%n</pattern>
            </layout>
        </appender>

        <logger name="com.atomikos" level="warn"/>
        <logger name="org.springframework" level="warn"/>
        <logger name="org.mybatis" level="warn"/>
        <logger name="org.apache" level="warn"/>
        <logger name="ch.qos.logback" level="warn"/>
        <logger name="org.apache.kafka.clients" level="error"/>


        <root level="info">
            <appender-ref ref="STDOUT"/>
            <appender-ref ref="FILE"/>
        </root>
    </springProfile>

    <!-- 生产环境. -->
    <springProfile name="product">
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <layout class="ch.qos.logback.classic.PatternLayout">
                <pattern>%d{ISO8601} [%thread] [%-5level] %logger - %msg%n</pattern>
            </layout>
        </appender>

        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>/home/quant_group/asset-distribution/logs/asset-distribution.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <fileNamePattern>/home/quant_group/asset-distribution/logs/asset-distribution.log.%d{yyyy-MM-dd}</fileNamePattern>
                <maxHistory>7</maxHistory>
            </rollingPolicy>
            <layout class="ch.qos.logback.classic.PatternLayout">
                <pattern>%d{ISO8601} [%thread] [%-5level] %logger - %msg%n</pattern>
            </layout>
        </appender>
        <!-- logstash -->
        <appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
            <destination>172.30.220.6:9650</destination>
            <!-- encoder is required -->
            <encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder" />
        </appender>

        <logger name="org.springframework" level="warn"/>
        <logger name="org.apache" level="warn"/>
        <logger name="ch.qos.logback" level="warn"/>
        <logger name="org.apache.kafka.clients" level="error"/>

        <root level="INFO">
            <appender-ref ref="FILE"/>
            <appender-ref ref="stash"/>
        </root>
    </springProfile>

</configuration>