liriming
2024-09-26 2070c06b8cc7b370c3a149669017f4f183f0f172
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
    <property name="LOG_TEMP" value="./logs"/>
    <include resource="org/springframework/boot/logging/logback/defaults.xml" />
    <!-- <include resource="org/springframework/boot/logging/logback/base.xml" /> -->
    <logger name="org.springframework.web" level="INFO"/>
    <logger name="org.springboot.sample" level="TRACE" />
 
    <!-- 开发、测试环境 -->
    <springProfile name="dev,test,prod">
        <logger name="org.springframework.web" level="INFO"/>
        <logger name="org.springboot.sample" level="INFO" />
        <logger name="com.iailab" level="DEBUG" />
    </springProfile>
 
    <!-- 生产环境 -->
    <!--<springProfile name="prod">-->
    <!--<logger name="org.springframework.web" level="ERROR"/>-->
    <!--<logger name="org.springboot.sample" level="ERROR" />-->
    <!--<logger name="io.renren" level="ERROR" />-->
    <!--</springProfile>-->
 
    <!-- 日志文件存放路径 -->
    <property name="log_home" value="./logs" />
    <!-- 日志输出格式 -->
    <!--生产用-->
    <property name="log.pattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] | [%thread][%-5level] | [%logger{20}.%method,line : %line] %msg%n" />
    <!--本地测试使用-->
    <!--<property name="log.pattern" value="[%boldGreen(%d{yyyy-MM-dd HH:mm:ss.SSS})] | [%highlight(%thread][%-5level)] | [%boldYellow(%logger{20}.%method,%line)] %msg%n" />-->
    <!-- 日志输出格式【控制台】 -->
    <!--<property name="log.pattern" value="%date{yyyy-MM-dd HH:mm:ss} | [ line: %line ] | %boldGreen(%thread) | %highlight(%-5level) | %boldYellow(%logger).%method | %msg%n"/>-->
 
    <!-- 控制台输出 -->
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <!--<pattern>${logPatternConsoleLog}</pattern>-->
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
 
    <logger name="m-shop-mybatis-sql" level="debug"></logger>
 
    <!-- debug级别设置 -->
    <appender name="file_debug"  class="ch.qos.logback.core.rolling.RollingFileAppender">
        <prudent>true</prudent>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <!--过滤 DEBUG-->
            <level>DEBUG</level>
            <!--匹配到就禁止-->
            <!--<onMatch>ACCEPT</onMatch>-->
            <!--没有匹配到就允许-->
            <!--<onMismatch>DENY</onMismatch>-->
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">-->
            <!--日志文件输出的文件名-->
            <!--<FileNamePattern>${log_home}/log-info.%d{yyyy-MM-dd}.%i.log</FileNamePattern>-->
            <FileNamePattern>${log_home}/log-debug.%d{yyyy-MM-dd}.log</FileNamePattern>
            <!--<maxFileSize>100MB</maxFileSize>-->
            <!-- 日志最大的历史 7天 -->
            <maxHistory>7</maxHistory>
            <totalSizeCap>2GB</totalSizeCap>
            <cleanHistoryOnStart>true</cleanHistoryOnStart>
        </rollingPolicy>
        <!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">-->
        <!--&lt;!&ndash; 单文件最大50MB &ndash;&gt;-->
        <!--<maxFileSize>50MB</maxFileSize>-->
        <!--</triggeringPolicy>-->
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
 
    <!-- 系统模块日志级别控制  -->
    <!--<logger name="com.btrh" level="info" />-->
 
    <!-- Spring日志级别控制  -->
    <!--<logger name="org.springframework" level="info" />-->
 
    <!--系统操作日志-->
    <root level="INFO">
        <appender-ref ref="console" />
        <appender-ref ref="file_debug" />
    </root>
 
</configuration>