<configuration>

    <property name="LOG_HOME" value="/data/jiage-sms-mis/log/jiage-sms-mis_8089"/>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>[%thread] %d{MM-dd HH:mm:ss} %-5level %-4relative %logger{50} - %msg%n
            </pattern>
        </encoder>
    </appender>

    <!-- 全部日志 -->
    <appender name="all" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/api-all.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/api-all.log.%d{yyyy-MM-dd}</fileNamePattern>
            <maxHistory>20</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>[%thread] %d{MM-dd HH:mm:ss} %-5level %-4relative %logger{0} - %msg%n</pattern>
        </encoder>
    </appender>

    <!-- 业务日志 -->
    <appender name="info" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <file>${LOG_HOME}/api-info.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/api-info.log.%d{yyyy-MM-dd}</fileNamePattern>
            <maxHistory>20</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>[%thread] %d{MM-dd HH:mm:ss} %-5level %-4relative %logger{0} - %msg%n</pattern>
        </encoder>
    </appender>


    <!-- 警告日志 -->
    <appender name="warn"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>WARN</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <file>${LOG_HOME}/api-warn.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/api-warn.log.%d{yyyy-MM-dd}</fileNamePattern>
            <maxHistory>20</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>[%thread] %d{MM-dd HH:mm:ss} %-5level %-4relative %logger{0} - %msg%n</pattern>
            <immediateFlush>false</immediateFlush>
        </encoder>
    </appender>

    <!-- 错误日志 -->
    <appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>
        <file>${LOG_HOME}/api-error.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/api-error.log.%d{yyyy-MM-dd}</fileNamePattern>
            <maxHistory>20</maxHistory>
        </rollingPolicy>
        <encoder>
            <!--<pattern>%d{MM-dd HH:mm:ss} [%t][%p][%c.%M\(\):%L] - %msg%n</pattern>-->
            <pattern>%d{yyyy-MM-dd HH:mm:ss}`%p`%c.%M\(\):%L`%msg%n</pattern>
        </encoder>
    </appender>

    <!-- MQ日志 -->
    <!--	<appender name="mq" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>/home/centos/logs/ownerprice_pc/ donkey-mq.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <fileNamePattern>/home/centos/logs/ownerprice_pc/ donkey-mq.log.%d{yyyy-MM-dd}</fileNamePattern>
                <maxHistory>20</maxHistory>
            </rollingPolicy>
            <encoder>
                <pattern>[%thread] %d{MM-dd HH:mm:ss} %-5level %-4relative %logger{0} - %msg%n</pattern>
            </encoder>
        </appender>-->

    <!-- SlowSQL -->
    <appender name="slowSql" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/slowSql.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>
                ${LOG_HOME}/api-slowSql.log.%d{yyyy-MM-dd}
            </fileNamePattern>
            <maxHistory>20</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>[%thread] %d{MM-dd HH:mm:ss} %-5level %-4relative %logger{0} - %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="monitor">
        <appender-ref ref="STDOUT"/>
    </logger>

    <!-- Loggers slow parameter-->
    <!--<logger name="logperf.filter" additivity="false">
        <appender-ref ref="timingslow"/>
    </logger>-->


    <!-- loggers -->
    <logger name="org.springframework" level="WARN"/>
    <logger name="com.alibaba.druid" level="WARN">
        <appender-ref ref="slowSql"/>
    </logger>

    <logger name="druid.sql" level="debug"></logger>

    <logger name="java.sql" level="debug"></logger>

    <root level="info">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="all"/>
        <appender-ref ref="info"/>
        <appender-ref ref="warn"/>
        <appender-ref ref="error"/>
    </root>

</configuration>
