当前位置:网站首页>Introduction to logback appender
Introduction to logback appender
2022-07-29 07:25:00 【qq_ twenty-five million seventy-three thousand two hundred and 】
from :
The following is about logback Of appender Introduction to , As shown below :
logback in appender It's the component responsible for writing logs
appender The function of : Used to set the destination of log output
The location of log output can be console 、 file 、 Remote socket server 、MySQL And other databases 、JMS And remote UNIX Syslog Daemons, etc
appender type
ConsoleAppender: Print the log to the console FileAppender: Output the log to a file RollingFileAppender: Output the log to a file by rolling records , That is, the log file can be split by file size or by date
example
<appender name="infoAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- File path -->
<file>${log.filePath}/info.log</file>
<!-- Rolling strategy -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- Set file name -->
<fileNamePattern>
${log.filePath}/info/info.%d{yyyy-MM-dd}.log.gz
</fileNamePattern>
<!-- Set the maximum save cycle -->
<MaxHistory>${log.maxHistory}</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<!-- filter , Filter out logs that are not at the specified log level -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- Set the log level -->
<level>INFO</level>
<!-- If it matches the log level , received -->
<onMatch>ACCEPT</onMatch>
<!-- If it does not match the log level , Filter out -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
logback Child node
filter filter
LevelFilter: Grade filter , Filter by log level . If the log level is equal to the configuration level , The filter will be based on onMath and onMismatch Receive or reject logs ThresholdFilter: Threshold filter , Filter out logs below the specified threshold . When the log level is equal to or higher than the threshold , Filter return NEUTRAL; When the log level is below the threshold , Logs will be rejected EvaluatorFilter: Evaluation filters , assessment 、 Identify whether the log meets the specified conditions
rollingPolicy
Used to set the rolling strategy of logs
When the condition is met, the log before the condition will be automatically generated into a backup log file
The log after the condition is output to the latest log file
Commonly used is to scroll by time ( Classes used TimeBaseRollingPolicy)
Another is to implement based on index ( Classes used FixedWindowRollingPolicy)
fileNamePattern Property to set the format of the rolling generation file , The setting here is accurate to days , That is, roll by day , If the time setting is accurate to seconds , Just scroll by seconds
maxHistory Property to set the maximum number of files , For example, scroll by day , I've set it up here 30 God , In the 31 When the daily log is generated , The log of the first day will be deleted
triggeringPolicy
Log trigger policy , Used to set the size of the log
When the log reaches the corresponding size , It will trigger
Generate a new log file . Log size control coordination rollingPlicy When you use it , Different rollingPolicy It will be different
encoder
encoder Property is used to convert the event into a byte array and write the byte array to the appropriate output stream
encoder Attribute values can be specified class, There is only one corresponding class PatternLayoutEncoder, It's also the default value , You don't have to specify
边栏推荐
- logback日志级别简介说明
- Gin parameter validation
- 个人博客系统(附源码)
- thinkphp6 实现数据库备份
- Full process flow of CMOS chip manufacturing
- MySQL uses the client and select methods to view the summary of blob type fields
- 同步/异步、阻塞/非阻塞 与 IO
- Kubernetes (V) -- deploy kubernetes dashboard
- Use vscode to configure Mysql to realize connection, query, and other functions
- fillder使用
猜你喜欢

WPF interface layout must know basis

Operator3 - design an operator

Win11vmware turns on the virtual machine and restarts on the blue screen and the solution that cannot be started

JS chicken laying eggs and egg laying chickens. Who appeared earlier, object or function? Is function an instance of function?

js第四天流程控制(if语句和switch语句)

After 4 years of development and 13K, if you want to change to automated testing, can your salary still rise···

MySQL----多表查询

如何与斯堪尼亚SCANIA建立EDI连接?

Excel文件读写(创建与解析)

CAN&CANFD综合测试分析软件LKMaster与PCAN-Explorer 6分析软件的优势对比
随机推荐
npm install报错npm ERR Could not resolve dependency npm ERR peer
请问flink支持sqlServer数据库么?获取sqlServer数据库的变化
Latest 10 billion quantitative private placement list
Vmware16 create virtual machine: win11 cannot be installed
logback appender简介说明
Paper reading (62):pointer networks
3-global exception handling
js中break与continue和return关键字
Some learning and understanding of vintage analysis
Remote invocation of microservices
How much data can a single MySQL table store at most?
路由中的生命周期钩子 - activated与deactivated
Operator3-设计一个operator
同步/异步、阻塞/非阻塞 与 IO
Variables and encryption in ansible
How to establish EDI connection with Scania in Scania?
MySQL 有这一篇就够(呕心狂敲37k字,只为博君一点赞!!!)
Spark Learning Notes (VII) -- spark core core programming - RDD serialization / dependency / persistence / partition / accumulator / broadcast variables
Vite3.0都发布了,你还能卷得动吗(新特性一览)
MySQL uses the client and select methods to view the summary of blob type fields