zoukankan      html  css  js  c++  java
  • 日志logback

    http://tengj.top/2017/04/05/springboot7/

    ------------------

    logback使用指南。

    公司配置

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration scan="true" scanPeriod="5 seconds" debug="true">
    
        <property resource="${profile.properties}/logback.properties" />
        <appender name="stdoutAppender" class="ch.qos.logback.core.ConsoleAppender">
            <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
                <level>${logback.stdoutLevel}</level>
            </filter>
            <!-- encoder 默认配置为PatternLayoutEncoder -->
            <encoder>
                <pattern>${logback.msg}</pattern>
            </encoder>
        </appender>
    
        <appender name="debugAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>${logback.userHome}/${logback.fileName}_${logback.rootLevel}${logback.suffix}</file>
    
            <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
                <level>${logback.rootLevel}</level>
            </filter>
    
            <encoder>
                <pattern>${logback.msg}</pattern>
            </encoder>
    
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <!-- rollover daily -->
                <fileNamePattern>${logback.userHome}/${logback.fileName}_${logback.rootLevel}_%d{${logback.datePattern}}.%i.log</fileNamePattern>
                <!-- keep ${logback.maxHistory} days' worth of history -->
                <maxHistory>${logback.maxHistory}</maxHistory>
                <timeBasedFileNamingAndTriggeringPolicy
                        class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                    <!-- or whenever the file size reaches ${logback.maxFileSize} -->
                    <maxFileSize>${logback.maxFileSize}</maxFileSize>
                </timeBasedFileNamingAndTriggeringPolicy>
            </rollingPolicy>
        </appender>
    
        <appender name="noticelog" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <File>${logback.userHome}/notice_${logback.rootLevel}.log</File>
    
            <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
                <level>${logback.rootLevel}</level>
            </filter>
    
            <encoder>
                <pattern>${logback.msg}</pattern>
            </encoder>
    
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <FileNamePattern>${logback.userHome}/notice_${logback.rootLevel}_%d{${logback.datePattern}}.%i.log</FileNamePattern>
                <maxHistory>${logback.maxHistory}</maxHistory>
                <timeBasedFileNamingAndTriggeringPolicy
                        class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                    <maxFileSize>${logback.maxFileSize}</maxFileSize>
                </timeBasedFileNamingAndTriggeringPolicy>
            </rollingPolicy>
        </appender>
        <logger name="NOTICE-LOG" additivity="false" level="debug">
            <appender-ref ref="noticelog"/>
            <appender-ref ref="debugAppender" />
        </logger>
    
        <logger name="org.apache.activemq" level="WARN" additivity="false">
            <appender-ref ref="debugAppender" />
        </logger>
    
        <logger name="org.apache.zookeeper" level="WARN" additivity="false">
            <appender-ref ref="debugAppender"/>
        </logger>
    
        <!-- TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF -->
        <root level="${logback.rootLevel}">
            <appender-ref ref="stdoutAppender" />
            <appender-ref ref="debugAppender" />
        </root>
    </configuration>

    配置文件

    logback.msg=%date [%thread] [%X{uid} - %X{url}] %-5level %logger{80} - %msg%n
    logback.suffix=.log
    logback.fileName=${project.artifactId}
    logback.userHome=./logs/${project.artifactId}
    #The date-and-time pattern, as found within the accolades of %d{} follow java.text.SimpleDateFormat conventions
    logback.datePattern=yyyy-MM-dd
    #keep ${logback.maxHistory} 'logback.datePattern' worth of history
    logback.maxHistory=30
    logback.maxFileSize=200MB
    #TRACE, DEBUG, INFO, WARN, ERROR, ALL, OFF
    logback.stdoutLevel=debug
    logback.rootLevel=debug
  • 相关阅读:
    bootstrap-scrollspy
    bootstrap-dropdown
    bootstrap-collapse
    如何带领团队“攻城略地”?优秀的架构师这样做
    detect data races The cost of race detection varies by program, but for a typical program, memory usage may increase by 5-10x and execution time by 2-20x.
    O(n) O(log n) blist: an asymptotically faster list-like type for Python
    搭建起中台后,不仅新业务可以直接获取90%以上的通用系统支持,还能降低试错成本,避免失去市场机会。
    Feed流系统设计-总纲
    大数据架构如何做到流批一体?
    大话数据库连接池
  • 原文地址:https://www.cnblogs.com/pingh/p/8435208.html
Copyright © 2011-2022 走看看