logback.xml 3.31 KB
<configuration> 
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
            <evaluator> <!-- defaults to type ch.qos.logback.classic.boolex.JaninoEventEvaluator -->
                <expression>logger.contains("springframework")</expression>
            </evaluator>
            <OnMismatch>NEUTRAL</OnMismatch>
            <OnMatch>DENY</OnMatch>
        </filter>

        <encoder charset="UTF-8">
            <pattern>%-4r - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n </pattern>
        </encoder>
    </appender>
    
    <appender name="PETSTORE-ALL" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${petstore.log.root}/petstore-all.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>petstore-all.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
        </rollingPolicy>
        <encoder>
            <pattern>%-1relative - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{0} -- %msg%n</pattern>
        </encoder>
    </appender>
    
    <appender name="PETSTORE-TIMEOUT-SQL" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${petstore.log.root}/petstore-timeout-sql.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>petstore-timeout-sql.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
        </rollingPolicy>
        <encoder>
            <pattern>%-1relative - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{0} -- %msg%n</pattern>
        </encoder>
    </appender>
    
    <appender name="PETSTORE-TIMEOUT-REQUEST" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${petstore.log.root}/petstore-timeout-request.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>petstore-timeout-request.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
        </rollingPolicy>

        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>5MB</maxFileSize>
        </triggeringPolicy>

        <encoder>
            <pattern>%-1relative - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{0} -- %msg%n</pattern>
        </encoder>
    </appender>

    <!-- ===================================================================== -->
    <!--  以下是logger的定义                                                   -->
    <!-- ===================================================================== -->
    <logger name="com.taobao.sample.petstore.dal.dao.ibatis.IbatisGenericDaoImpl" additivity="true">
        <level value="DEBUG"/>
        <appender-ref ref="PETSTORE-TIMEOUT-SQL"/>
    </logger>
    
    <logger name="com.milanoo.zeus.web.filter.timer.TimerFilter" additivity="true">
        <level value="WARN"/>
        <appender-ref ref="PETSTORE-TIMEOUT-REQUEST"/>
    </logger>

    <!-- ===================================================================== -->
    <!--  Root logger的定义                                                    -->
    <!-- ===================================================================== --> 
    <root level="${petstore.log.level}">
    	<appender-ref ref="STDOUT" />
    	<appender-ref ref="PETSTORE-ALL" />
    </root>
</configuration>