logback-spring.xml 2.5 KB
Newer Older
Q
qinyingjie 已提交
1
<?xml version="1.0" encoding="UTF-8"?>
2 3 4 5 6 7
<configuration>
    <property name="log.charset" value="utf-8"/>
    <property name="console.log.pattern"
              value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %blue(%msg%n)"/>
    <property name="file.log.pattern"
              value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
Q
qinyingjie 已提交
8

9
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
Q
qinyingjie 已提交
10
        <encoder>
11 12
            <pattern>${console.log.pattern}</pattern>
            <charset>${log.charset}</charset>
Q
qinyingjie 已提交
13 14 15
        </encoder>
    </appender>

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
    <springProfile name="dev,test,uat">
        <property name="log.dir" value="./logs/"/>
        <property name="file.log.pattern"
                  value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} %-5level [%thread] %logger{36} - %msg%n"/>

        <appender name="SYSTEM_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">            
                <fileNamePattern>${log.dir}system/%d.log</fileNamePattern>  
            </rollingPolicy>
            <encoder>
                <pattern>${file.log.pattern}</pattern>
                <charset>${log.charset}</charset>
            </encoder>
            <append>true</append>
        </appender>

        <appender name="SQL_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">            
                <fileNamePattern>${log.dir}/sql/%d.log</fileNamePattern>  
            </rollingPolicy>
            <encoder>
                <pattern>${file.log.pattern}</pattern>
                <charset>${log.charset}</charset>
            </encoder>
            <append>true</append>
        </appender>
    </springProfile>

    <springProfile name="local">
        <logger name="com.kwan.springbootkwan.mapper" level="DEBUG" additivity="false">
            <appender-ref ref="STDOUT"/>
        </logger>
        <root level="INFO">
            <appender-ref ref="STDOUT"/>
        </root>
    </springProfile>
Q
qinyingjie 已提交
52

53 54 55 56
    <springProfile name="dev,test,uat">
        <logger name="com.kwan.springbootkwan.mapper" level="DEBUG" additivity="false">
            <appender-ref ref="SQL_LOG"/>
        </logger>
Q
qinyingjie 已提交
57

58 59 60 61
        <root level="INFO">
            <appender-ref ref="SYSTEM_LOG"/>
        </root>
    </springProfile>
Q
qinyingjie 已提交
62
</configuration>