码迷,mamicode.com
首页 > 其他好文 > 详细

log

时间:2017-02-03 10:57:12      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:lte   fatal   err   erro   超出   保留   活动   mis   lin   

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <!--按照范围从小到大排序:OFF level > FATAL > ERROR > WARN > INFO > DEBUG > ALL level;范围大的会包含范围小的-->

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <!-- encoder对日志进行格式化-->
        <encoder>
            <pattern>
                [ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n
            </pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>


    <appender name="FILE-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被写入的文件名-->
        <File>${LOG_PATH}/info.log</File>
        <!--<rollingPolicy>:当发生滚动时,决定 RollingFileAppender 的行为,涉及文件移动和重命名-->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_PATH}/info-%d{yyyyMMdd}.log.%i</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <!--活动文件的大小-->
                <maxFileSize>50MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <!--控制保留的归档文件的最大数量,超出数量就删除旧文件,单位:月-->
            <maxHistory>2</maxHistory>
        </rollingPolicy>
        <!-- encoder对日志进行格式化-->
        <encoder>
            <pattern>
                [ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n
            </pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <appender name="FILE-ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <File>${LOG_PATH}/error.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_PATH}/info-%d{yyyyMMdd}.log.%i</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>50MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <maxHistory>2</maxHistory>
        </rollingPolicy>

        <!-- encoder对日志进行格式化-->
        <encoder>
            <pattern>
                [ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n
            </pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <appender name="FILE-DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>DEBUG</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <File>${LOG_PATH}/debug.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_PATH}/info-%d{yyyyMMdd}.log.%i</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>50MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <maxHistory>2</maxHistory>
        </rollingPolicy>
        <!-- encoder对日志进行格式化-->
        <encoder>
            <pattern>
                [ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n
            </pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>


    <springProfile name="dev">
        <logger name="com.jd" level="INFO">
            <appender-ref ref="FILE-ERROR"/>
            <appender-ref ref="FILE-INFO"/>
        </logger>
        <logger name="org.springframework" level="WARN">
            <appender-ref ref="FILE-ERROR"/>
            <appender-ref ref="FILE-INFO"/>
        </logger>
    </springProfile>

    <springProfile name="local">
        <logger name="com.aa" level="DEBUG">
            <appender-ref ref="FILE-ERROR"/>
            <appender-ref ref="FILE-INFO"/>
            <!--<appender-ref ref="FILE-DEBUG"/>-->
        </logger>
        <logger name="org.springframework" level="DEBUG">
            <appender-ref ref="FILE-ERROR"/>
            <appender-ref ref="FILE-INFO"/>
            <!--<appender-ref ref="FILE-DEBUG"/>-->
        </logger>
    </springProfile>

    <springProfile name="prod">
        <logger name="com.jd" level="INFO">
            <appender-ref ref="FILE-ERROR"/>
            <appender-ref ref="FILE-INFO"/>
        </logger>
        <logger name="org.springframework" level="WARN">
            <appender-ref ref="FILE-ERROR"/>
            <appender-ref ref="FILE-INFO"/>
        </logger>
    </springProfile>

    <root level="INFO">
        <appender-ref ref="CONSOLE"/>
    </root>

</configuration>

 

log

标签:lte   fatal   err   erro   超出   保留   活动   mis   lin   

原文地址:http://www.cnblogs.com/zhangjianbin/p/6362056.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!