<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="false" scanPeriod="60 seconds">
    <springProperty scope="context" name="LOG_HOME" source="logging.path" defaultValue="/home/server/log/"/>
    <property name="FileNamePattern" value="${LOG_HOME}%d{yyyyMM}/%d{dd}"/>

    <!-- 定义控制台输出 -->
    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} - [%thread] - %-5level - %logger{50} - %msg%n</pattern>
        </layout>
    </appender>

    <appender name="appLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!-- 指定日志文件的名称 -->
        <!--<file>${FileNamePattern}/info.log</file>-->

        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${FileNamePattern}/info-%i.log</fileNamePattern>
            <MaxHistory>30</MaxHistory>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <MaxFileSize>30MB</MaxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>

        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [ %thread ] - [ %-5level ] [ %logger{50} : %line ] - %msg%n</pattern>
        </layout>
    </appender>

    <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
        <discriminator>
            <Key>processid</Key>
            <DefaultValue>sys</DefaultValue>
        </discriminator>
        <sift>
            <appender name="FILE-${processid}"
                      class="ch.qos.logback.core.rolling.RollingFileAppender">
                <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                    <FileNamePattern>
                        ${FileNamePattern}/${processid}.log
                    </FileNamePattern>
                    <maxHistory>30</maxHistory>
                </rollingPolicy>
                <layout class="ch.qos.logback.classic.PatternLayout">
                    <Pattern>
                        %d{yyyyMMdd:HH:mm:ss.SSS} [%thread] %-5level %msg%n
                    </Pattern>
                </layout>
            </appender>
        </sift>
    </appender>

    <!-- 日志输出级别 -->
    <logger name="org.springframework" level="debug"  additivity="false"/>
    <logger name="com.malk.connecter" level="debug"/>
    <root level="INFO">
        <appender-ref ref="stdout"/>
        <appender-ref ref="appLogAppender"/>
        <appender-ref ref="SIFT"/>
    </root>
</configuration>