• logback配置


    小Demo 

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration scan="false" scanPeriod="60 seconds" debug="false">
    <contextName>wsbs</contextName>
    <!-- 定义日志出输出路径 -->
    <property name="LOG_PATH" value="./data/logs/wsbs" />
    <property name="LOG_PATTERN"
    value=".%d{yyyy/MM/dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %n" />
    <!-- <property name="LOG_PATTERN" value= ".%d{HH:mm:ss.SSS} [%thread] %-5level
    %logger{36} - %msg %n" /> -->

    <!-- 控制台输出 -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
    <Pattern>
    ${LOG_PATTERN}
    </Pattern>
    </encoder>
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
    <level>TRACE</level>
    </filter>
    </appender>

    <!-- 按天滚动文件输出 -->
    <appender name="FILE"
    class="ch.qos.logback.core.rolling.RollingFileAppender">
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
    <level>INFO</level>
    </filter>
    <File>${LOG_PATH}/all_log.txt</File>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <!-- daily rollover -->
    <FileNamePattern>
    ${LOG_PATH}/all_log.%d{yyyy-MM-dd}.%i.txt
    </FileNamePattern>
    <timeBasedFileNamingAndTriggeringPolicy
    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
    <maxFileSize>300MB</maxFileSize>
    </timeBasedFileNamingAndTriggeringPolicy>
    <!-- keep 30 days' worth of history -->
    <maxHistory>30</maxHistory>
    </rollingPolicy>
    <!-- append是否接着上次写文件结尾继续写,默认为true -->
    <append>true</append>
    <encoder>
    <Pattern>
    ${LOG_PATTERN}
    </Pattern>
    </encoder>
    </appender>

    <!-- spring日志输出 -->
    <logger name="org.springframework" level="WARN" />
    <logger name="com.netflix" level="WARN" />
    <logger name="org.apache.http" level="WARN" />
    <logger name="org.apache.coyote" level="WARN" />
    <logger name="ch.qos.logback" level="WARN" />
    <logger name="druid.sql" level="WARN" />
    <logger name="com.alibaba.druid" level="WARN" />

    <!-- hibernate日志输出 -->
    <logger name="org.hibernate" level="WARN" />
    <logger name="org.hibernate.type.descriptor.sql.BasicBinder"
    level="DEBUG" />
    <logger name="org.hibernate.type.descriptor.sql.BasicExtractor"
    level="DEBUG" />
    <logger name="org.hibernate.SQL" level="DEBUG" />
    <logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
    <logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />

    <!-- 配置sql中日志输出级别 -->
    <logger name="java.sql" level="DEBUG" />

    <!-- 配置ibatis中日志输出级别 -->
    <logger name="org.mybatis" level="WARN" />
    <logger name="org.apache.ibatis" level="WARN" />
    <!-- 配置ibatis中日志输出级别 -->
    <logger name="org.springframework.data.mongodb.core" level="DEBUG" />
    <logger name="org.mongodb.driver" level="WARN" />

    <!-- 项目代码日志级别 -->
    <logger name="com.ysyc" level="DEBUG" additivity="true" />

    <!-- 开发环境 -->
    <springProfile name="dev">
    <logger name="com.ysyc" level="DEBUG" additivity="true" />
    </springProfile>
    <!-- 生产环境 -->
    <springProfile name="prod">
    <logger name="com.ysyc" level="INFO" additivity="true" />
    </springProfile>
    <!-- 开发环境 -->
    <springProfile name="test">
    <logger name="com.ysyc" level="DEBUG" additivity="true" />
    </springProfile>

    <root level="DEBUG">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="FILE" />
    </root>
    </configuration>

    参考:http://www.cnblogs.com/warking/p/5710303.html
  • 相关阅读:
    Linux下监视GPU、CPU的使用情况
    2014多校第一场 E 题 || HDU 4865 Peter's Hobby (DP)
    2014多校第一场 I 题 || HDU 4869 Turn the pokers(费马小定理+快速幂模)
    2014多校第一场D题 || HDU 4864 Task (贪心)
    2014多校第一场J题 || HDU 4870 Rating(DP || 高斯消元)
    2014多校第一场A题 || HDU 4861 Couple doubi
    POJ 2948 Martian Mining(DP)
    POJ 2029 Get Many Persimmon Trees(DP||二维树状数组)
    POJ 3280 Cheapest Palindrome(DP)
    POJ 4044 Score Sequence
  • 原文地址:https://www.cnblogs.com/xingzc/p/9020889.html
Copyright © 2020-2023  润新知