• logback的简单配置详解


    
    
    <configuration scan="true" scanPeriod="30 seconds">
    
        
        <property name="LOG_HOME" value="/data/logs/sys_admin"/>
        
        
        <property name="ENCODER_PATTERN"
                  value="%d{yyyy-MM-dd HH:mm:ss.SSS} %X{traceId} %level %logger{0} [%t] %m%n"/>
        
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
                <pattern>${ENCODER_PATTERN}pattern>
            encoder>
        appender>
    
        
        
        <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            
            <Append>trueAppend>
            
            <file>${LOG_HOME}/sys_info.logfile>
            
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                
                <FileNamePattern>${LOG_HOME}/sys_info.log.%d{yyyy-MM-dd}FileNamePattern>
                
                <MaxHistory>30MaxHistory>
            rollingPolicy>
            
            <encoder>
                <pattern>${ENCODER_PATTERN}pattern>
                <charset>UTF-8charset>
            encoder>
            
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
                
                <level>INFOlevel>
                
                <onMatch>ACCEPTonMatch>
                
                <onMismatch>DENYonMismatch>
            filter>
        appender>
    
        
        <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <Append>trueAppend>
            <file>${LOG_HOME}/sys_error.logfile>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                
                <FileNamePattern>${LOG_HOME}/sys_error.log.%d{yyyy-MM-dd}
                FileNamePattern>
                
                <MaxHistory>30MaxHistory>
            rollingPolicy>
            <encoder>
                <pattern>${ENCODER_PATTERN}pattern>
                <charset>UTF-8charset>
            encoder>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
                <level>ERRORlevel>
                <onMatch>ACCEPTonMatch>
                <onMismatch>DENYonMismatch>
            filter>
        appender>
    
        
        <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <Append>trueAppend>
            <file>${LOG_HOME}/sys_warn.logfile>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                
                <FileNamePattern>${LOG_HOME}/sys_warn.log.%d{yyyy-MM-dd}
                FileNamePattern>
                
                <MaxHistory>30MaxHistory>
            rollingPolicy>
            <encoder>
                <pattern>${ENCODER_PATTERN}pattern>
                <charset>UTF-8charset>
            encoder>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
                <level>WARNlevel>
                <onMatch>ACCEPTonMatch>
                <onMismatch>DENYonMismatch>
            filter>
        appender>
    
        <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <Append>trueAppend>
            <file>${LOG_HOME}/sys_debug.logfile>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                
                <FileNamePattern>${LOG_HOME}/sys_debug.log.%d{yyyy-MM-dd}
                FileNamePattern>
                
                <MaxHistory>30MaxHistory>
            rollingPolicy>
            <encoder>
                <pattern>${ENCODER_PATTERN}pattern>
                <charset>UTF-8charset>
            encoder>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
                <level>DEBUGlevel>
                <onMatch>ACCEPTonMatch>
                <onMismatch>DENYonMismatch>
            filter>
        appender>
    
        <appender name="trace" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>/data/logs/trace/trace.logfile>
            <Append>trueAppend>
            <encoder>
                
                <pattern>%msg%npattern>
                <charset>UTF-8charset>
            encoder>
    
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                
                <FileNamePattern>/data/logs/trace/trace.log.%d{yyyy-MM-dd-HH}FileNamePattern>
                
                <MaxHistory>1MaxHistory>
            rollingPolicy>
        appender>
    
        
        <appender name="async-trace" class="ch.qos.logback.classic.AsyncAppender">
            
            <discardingThreshold>80discardingThreshold>
            
            <queueSize>512queueSize>
            
            <appender-ref ref="trace"/>
        appender>
    
        
        <logger name="cn.system.trace.utils.SpanLogger" additivity="false">
            <level value="INFO"/>
            <appender-ref ref="async-trace"/>
        logger>
    
        <logger name="cn.system.jade.datasource.SQLParseInfo" additivity="false">
            <level value="INFO"/>
            <appender-ref ref="WARN_FILE"/>
        logger>
    
        
        
        <root>
            
            <level value="INFO"/>
            
            <appender-ref ref="STDOUT"/>
            
            <appender-ref ref="INFO_FILE"/>
            <appender-ref ref="WARN_FILE"/>
            <appender-ref ref="ERROR_FILE"/>
            <appender-ref ref="DEBUG_FILE"/>
        root>
    configuration>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 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
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
  • 相关阅读:
    修改 Stable Diffusion 使 api 接口增加模型参数
    《lwip学习7》-- IP协议
    PMP认证有什么好处?该怎么考?
    R语言使用epiDisplay包的pyramid函数可视化金字塔图、基于已有的汇总数据(表格数据)可视化金字塔图、使用main参数添加自定义标题信息
    EasyExcel处理Mysql百万数据的导入导出案例,秒级效率,拿来即用!
    java通过lock实现同步锁
    小程序获取支付api
    理解ROS tf
    ubuntu虚拟机中安装Hadoop全过程(单机分布方式+伪分布方式)
    h5利用canvas截取video视频
  • 原文地址:https://blog.csdn.net/weixin_42684418/article/details/133812710