当前位置:网站首页>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>边栏推荐
- Paper reading (62):pointer networks
- 1-后台项目搭建
- Nodejs installation tutorial
- Redis Basics
- Variables and encryption in ansible
- QT专题:基础部件(按钮类,布局类,输出类,输入类,容器类)
- JS 鸡生蛋与蛋生鸡问题,Object与Function究竟谁出现的更早?Function算不算Function的实例?
- Practice of online problem feedback module (XVII): realize the online download function of excel template
- 接口测试实战项目03:执行测试用例
- Win11 system error: code execution cannot continue because ierutil.dll cannot be found. Reinstalling the program may fix this problem
猜你喜欢

js中break与continue和return关键字

CMOS芯片制造全工艺流程

Operator3-设计一个operator

Excel file reading and writing (creation and parsing)

Vmware16 create virtual machine: win11 cannot be installed

2022-07-28:以下go语言代码输出什么?A:AA;B:AB;C:BA;D:BB。 package main import ( “fmt“ ) func main() { f

CVPR2021| 基于自监督学习的多视图立体匹配 (CVPR2021)
![[OpenGL] use of shaders](/img/73/1322afec8add6462ca4b82cb8112d1.png)
[OpenGL] use of shaders

Spingboot integrates the quartz framework to realize dynamic scheduled tasks (support real-time addition, deletion, modification and query tasks)

WPF interface layout must know basis
随机推荐
Unity sends a post request to the golang server for parsing and returning
Excel file reading and writing (creation and parsing)
亚马逊云助手小程序来啦!
BeanUtils.setProperty()
Operator3 - design an operator
QT基础第二天(2)qt基础部件:按钮类,布局类,输出类,输入类,容器等个别举例
Scala 高阶(九):Scala中的模式匹配
mysql 单表最多能存多少数据?
Unity发送Post请求给GoLang服务端解析并返回
Latest 10 billion quantitative private placement list
Explanation of suffix automata (SAM) + Luogu p3804 [template] suffix automata (SAM)
女研究生做“思维导图”与男友吵架!网友:吵架届的“内卷之王”....
第7节-程序的编译(预处理操作)+链接
JS 鸡生蛋与蛋生鸡问题,Object与Function究竟谁出现的更早?Function算不算Function的实例?
Remote invocation of microservices
OCR光学字符识别方法汇总
请问flink支持sqlServer数据库么?获取sqlServer数据库的变化
20-40K| 梅卡曼德3D视觉算法/软件/产品经理招聘
js中break与continue和return关键字
WPF nested layout case