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

    <springProperty scope="context" name="filePath" source="log.file.path"/>
    <springProperty scope="context" name="fileName" source="log.file.name"/>

    <!-- 默认的控制台日志输出，一般生产环境都是后台启动，这个没太大作用 -->
    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
        <!--<Encoding>UTF-8</Encoding>-->
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%date [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
        </layout>
    </appender>

    <!-- 配置文件轮转 -->
    <appender name="logfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!--<Encoding>UTF-8</Encoding>-->
        <File>${filePath}/${fileName}</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>${filePath}/history/service.%d{yyyy-MM-dd}.log.gz</FileNamePattern>
            <maxHistory>30</maxHistory>
        </rollingPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%date [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
        </layout>
    </appender>


    <!-- 修改其他包的日志输出级别 -->
    <logger name="org.apache.zookeeper">
        <level value="WARN"/>
    </logger>

    <!-- root 默认日志配置 ， 注意这里的级别哈！小心生产环境用DEBUG，压爆你的磁盘！-->
    <root level="INFO">
        <appender-ref ref="logfile"/>
        <appender-ref ref="stdout"/>
    </root>
</configuration>