当前位置:网站首页>Logback configuration file
Logback configuration file
2022-07-03 00:28:00 【Cold Snowflakes】
You can see , Imported web After dependence , In fact, there is a log module embedded .
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
The solution is IDEA Inject DAO It's a mistake , edit Inspection Setting, take Severity from Error Change it to Warning
pattern Parameters
%c / class, Output the fully qualified name of the execution record request . Avoid using , Unless the execution speed does not cause any problems .
%F / file, The output executes the record request Java The source file name . Avoid using , Unless the execution speed does not cause any problems .
%L / line, Output the line number of the execution log request . Avoid using , Unless the execution speed does not cause any problems .
%m / msg / message, Output information provided by the application .
%M / method, Output the method name of the execution log request . Avoid using , Unless the execution speed does not cause any problems .
%r / relative, Output the time from program startup to log creation , In milliseconds .
The optional format modifier is located at "%" And the conversion character
Align left sign , The sign is a minus sign “-”; Then comes the optional minimum width , In decimal notation . If the character is less than the minimum width , Fill it .
Maximum width Modifier , The sign is a dot “.” Add decimal number after . If the character is greater than the maximum width , Cut from the front . Dot notation “.” Add a minus sign to the back “-” Adding numbers , To cut off from the tail .
%-20.40c # Minimum width 20, Maximum width 40, Cut off if it's not enough , Fill in the remaining space , - yes Align left
Some of the parameters
Log information output destination
1.org.apache.log4j.ConsoleAppender( Console )
2.FileAppender( file )
3.DailyRollingFileAppender( Generate a log file every day )
4.RollingFileAppender( A new file is generated when the file size reaches the specified size )
5.WriterAppender( Send log information in stream format to any specified place )
Format of log information
1.org.apache.log4j.HTMLLayout(HTML Tabular layout )
2.PatternLayout( Specify layout mode )
3.SimpleLayout( The level of log information and information string )
4.TTCCLayout( Log generation time 、 Threads 、 Category and other information )
My configuration
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Defining variables -->
<property name="LOG_PATH" value="logs" />
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %-40.40logger{39} : %msg%n" />
<!-- Output to console -->
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>
%d{yyyy-MM-dd HH:mm:ss} %blue([%thread]) %highlight(%-5level) %green([%-20.40c]).%M\(%F:%L\) >>> %cyan(%msg) %n
</pattern>
</layout>
</appender>
<!-- Generate log files -->
<appender name="fileLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- The file name and save path of the log file -->
<FileNamePattern>${LOG_PATH}/logback.%d{yyyy-MM-dd}.[%i].log</FileNamePattern>
<!-- Maximum log file size -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- Log file retention days -->
<MaxHistory>2</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- Log output level -->
<!-- At most one can be configured root -->
<root level="info">
<appender-ref ref="Console" />
<appender-ref ref="fileLog" />
</root>
</configuration>
logback Color log configuration and banner Startup settings
logback Color character coding
spring boot logback
logback.xml To configure
logback Official website configuration
边栏推荐
- 监控容器运行时工具Falco
- Program analysis and Optimization - 9 appendix XLA buffer assignment
- 大学生课堂作业2000~3000字的小论文,标准格式是什么?
- Architecture: database architecture design
- mm中的GAN模型架构
- 可下载《2022年中国数字化办公市场研究报告》详解1768亿元市场
- Chapter 4 of getting started with MySQL: data types stored in data tables
- Andorid 获取系统标题栏高度
- 写论文可以去哪些网站搜索参考文献?
- Which websites can I search for references when writing a thesis?
猜你喜欢
Is the multitasking loss in pytoch added up or backward separately?
Bloom filter
有哪些比较推荐的论文翻译软件?
Talk with the interviewer about the pit of MySQL sorting (including: duplicate data problem in order by limit page)
Introduction of UART, RS232, RS485, I2C and SPI
Where can I find the English literature of the thesis (except HowNet)?
Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
Bigder: how to deal with the bugs found in the 32/100 test if they are not bugs
JS interviewer wants to know how much you understand call, apply, bind no regrets series
Multiprocess programming (II): Pipeline
随机推荐
pageoffice-之bug修改之旅
LeedCode1480. Dynamic sum of one-dimensional array
Introduction of UART, RS232, RS485, I2C and SPI
LeedCode1480.一维数组的动态和
Centos7 one click compilation to build MySQL script
Go custom sort
【雅思阅读】王希伟阅读P2(阅读填空)
redis21道经典面试题,极限拉扯面试官
请问大家在什么网站上能查到英文文献?
Basic use of shell script
Andorid gets the system title bar height
v8
AcWing_ 188. Warrior cattle_ bfs
奥斯陆大学:Li Meng | 基于Swin-Transformer的深度强化学习
详解用OpenCV的轮廓检测函数findContours()得到的轮廓拓扑结构(hiararchy)矩阵的意义、以及怎样用轮廓拓扑结构矩阵绘制轮廓拓扑结构图
TypeError: Cannot read properties of undefined (reading ***)
node_modules删不掉
What is the standard format of a 2000-3000 word essay for college students' classroom homework?
Seckill system design
Markdown使用教程