当前位置:网站首页>Description of rollingfileappender attribute in logback
Description of rollingfileappender attribute in logback
2022-07-29 07:24:00 【qq_ twenty-five million seventy-three thousand two hundred and 】
from :
logback in RollingFileAppender Description of property introduction
The following is about logback in RollingFileAppender Property setting method sharing , As shown below :
logback in RollingFileAppender For scrolling record files First log to the specified file When a condition is met , Log to other files RollingFileAppender attribute
<file>: The name of the file being written , It can be a relative Directory , It can also be an absolute catalog
If the parent directory does not exist, it will be created automatically , No default
<append>: When set to true, The log is appended to the end of the file
When set to false, Empty existing files , The default is true
<rollingPolicy>: When rolling happens , decision RollingFileAppender act , It involves moving and renaming files
attribute class Define specific rolling strategy classes ,"ch.qos.logback.core.rolling.TimeBasedRollingPolicy" Is the most commonly used scrolling strategy
It makes rolling strategies based on time , Responsible for rolling as well as starting rolling .
<fileNamePattern>: Necessary nodes , Contains the file name and “%d” Conversion character ,“%d” It can contain a java.text.SimpleDateFormat Specified time format , Such as :%d{yyyy-MM}
When used directly %d, The default format is yyyy-MM-dd
RollingFileAppender Of file Byte points are optional , By setting file
You can specify different locations for active and archived files , The current log always records file Specified file ( Activity file )
The name of the active file will not change
If not file, The name of the activity file will be based on fileNamePattern Value
Change every once in a while
“/” perhaps “\” Will be used as a directory separator
<maxHistory>: Optional nodes , Control the maximum number of archive files that are retained , Delete old files if the number exceeds
Suppose you set the scroll every month , And <maxHistory> yes 6, Save only recent 6 Months of documents , Delete old files before
Be careful , Deleting old files is , Directories created for archiving will also be deleted ."ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy" Is to view the size of the currently active file ,
If it exceeds the specified size, it will inform RollingFileAppender Triggers the scrolling of the currently active file . Only one node :
<maxFileSize>: This is the size of the active file , The default value is 10MB.
<prudent>: When it comes to true when , I won't support it FixedWindowRollingPolicy
Support TimeBasedRollingPolicy, But there are two limitations ,1 File compression is not supported or allowed ,2 Cannot set file attribute , Must be left blank .
<triggeringPolicy >: inform RollingFileAppender Appropriate to activate scrolling ."ch.qos.logback.core.rolling.FixedWindowRollingPolicy"
According to the fixed window algorithm rename the file rolling strategy .
<minIndex>: Minimum window index
<maxIndex>: Maximum window index , When the window specified by the user is too large , Will automatically set the window to 12.
<fileNamePattern>: Must contain “%i” for example , Suppose that the minimum and maximum values are respectively 1 and 2, The naming pattern is mylog%i.log,
There will be an archive mylog1.log and mylog2.log. You can also specify file compression options , for example ,mylog%i.log.gz Or not log%i.log.zip
<encoder>: Format the recorded events . Responsible for two things ,
One is to convert log information into byte array
The second is to write the byte array to the output stream
PatternLayoutEncoder Is the only useful and default encoder
There is one <pattern> node , Used to set the input format of the log
Use “%” Add “ Conversion character ” The way , If you want to output “%”, You have to use “\” Yes “\%” Transference
example
// Generate a log file every day , preservation 20 Days of log files
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>20</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration>边栏推荐
- Gin parameter validation
- 利用C语言巧妙实现棋类游戏——三子棋
- 0 8 动态规划(Dynamic Programming)
- After 4 years of development and 13K, if you want to change to automated testing, can your salary still rise···
- Personal blog system (with source code)
- 微服务远程调用
- QT专题:基础部件(按钮类,布局类,输出类,输入类,容器类)
- 5-整合swagger2
- Scala 高阶(九):Scala中的模式匹配
- Homebrew brew update 长时间没反应(或卡在 Updating Homebrew...)
猜你喜欢

2022-07-28: what is the output of the following go language code? A:AA; B:AB; C:BA; D:BB。 package main import ( “fmt“ ) func main() { f

Operator3 - design an operator

Full process flow of CMOS chip manufacturing

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

2-统一返回类DTO对象

MySQL如何把行转换为列?

Nodejs安装教程
![Explanation of suffix automata (SAM) + Luogu p3804 [template] suffix automata (SAM)](/img/8b/f68503e09f218c26e34453b1b7fcd5.png)
Explanation of suffix automata (SAM) + Luogu p3804 [template] suffix automata (SAM)

H3C_ Using setting default static routing priority to realize the active and standby function of export dual lines

0 9 布隆过滤器(Bloom Filter)
随机推荐
QT专题:基础部件(按钮类,布局类,输出类,输入类,容器类)
使用VsCode配置MySQL实现连接、查询、等功能
Why does ETL often become ELT or even let?
Gin routing, parameters, output
Does Flink support sqlserver databases? Get the changes of SQLSERVER database
Personal blog system (with source code)
vue-router路由缓存
Some learning and understanding of vintage analysis
Guess the number / / generate a random number for the first time
Variables and encryption in ansible
Gin Middleware
Comparison of advantages between can & canfd integrated test analysis software lkmaster and PCA Explorer 6 analysis software
mysql 单表最多能存多少数据?
Life cycle hooks in routing - activated and deactivated
Vmware16 create virtual machine: win11 cannot be installed
MySQL如何把行转换为列?
5-integrate swagger2
微服务远程调用
Full process flow of CMOS chip manufacturing
Remote invocation of microservices