Blame view

logback-spring.xml 2.82 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
    <property name="LOG_PATH" value="logs/" />
    <property name="APP_NAME" value="springboot-logback" />
    <contextName>${APP_NAME}</contextName>
    <jmxConfigurator />

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
涂亚平 committed
10
            <level>info</level>
涂亚平 committed
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
        </filter>
        <encoder>
            <pattern>%d [%t] %5p %c:%L - %m%n</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>
    <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>${LOG_PATH}${APP_NAME}-info.log</File>
        <encoder>
            <pattern>%d [%t] %5p %c:%L - %m%n</pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <FileNamePattern>${LOG_PATH}${APP_NAME}/info/%d{yyyy-MM-dd}-%i.log.gz
            </FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
    </appender>
    <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>${LOG_PATH}${APP_NAME}-error.log</File>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>error</level>
        </filter>
        <encoder>
            <pattern>%d [%t] %5p %c:%L - %m%n</pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>256MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <FileNamePattern>${LOG_PATH}${APP_NAME}/error/%d{yyyy-MM-dd}-%i.log.gz
            </FileNamePattern>
涂亚平 committed
45
            <MaxHistory>180</MaxHistory>
涂亚平 committed
46 47 48 49
        </rollingPolicy>
    </appender>

    <springProfile name="dev">
涂亚平 committed
50
        <logger name="com.subsidy" level="error" />
涂亚平 committed
51 52 53 54 55 56 57 58
        <root level="INFO">
            <appender-ref ref="CONSOLE" />
            <appender-ref ref="INFO_FILE" />
            <appender-ref ref="ERROR_FILE" />
        </root>
    </springProfile>

    <springProfile name="pre">
涂亚平 committed
59
        <logger name="com.subsidy" level="error" />
涂亚平 committed
60 61 62 63 64 65
        <root level="INFO">
            <appender-ref ref="ERROR_FILE" />
        </root>
    </springProfile>

    <springProfile name="prod">
涂亚平 committed
66
        <logger name="com.subsidy" level="error" />
涂亚平 committed
67 68 69 70 71 72
        <root level="INFO">
            <appender-ref ref="ERROR_FILE" />
        </root>
    </springProfile>

</configuration>