当前位置:网站首页>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
边栏推荐
- AcWing_ 188. Warrior cattle_ bfs
- NC24325 [USACO 2012 Mar S]Flowerpot
- 洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表
- Which software can translate an English paper in its entirety?
- [shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)
- zhvoice
- 可下载《2022年中国数字化办公市场研究报告》详解1768亿元市场
- Slf4j + logback logging framework
- Pytorch里面多任务Loss是加起来还是分别backward?
- 多进程编程(三):消息队列
猜你喜欢

Automated defect analysis in electron microscopic images-论文阅读笔记
![[target detection] r-cnn, fast r-cnn, fast r-cnn learning](/img/f0/df285f01ffadff62eb3dcb92f2e04f.jpg)
[target detection] r-cnn, fast r-cnn, fast r-cnn learning

Explain in detail the significance of the contour topology matrix obtained by using the contour detection function findcontours() of OpenCV, and how to draw the contour topology map with the contour t

带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)

TypeError: Cannot read properties of undefined (reading ***)

How do educators find foreign language references?

Pytorch里面多任务Loss是加起来还是分别backward?
![Luogu_ P2010 [noip2016 popularization group] reply date_ Half enumeration](/img/a3/55bb71d39801ceeee421a0c8ded333.png)
Luogu_ P2010 [noip2016 popularization group] reply date_ Half enumeration

Feature Engineering: summary of common feature transformation methods

redis21道经典面试题,极限拉扯面试官
随机推荐
NC24840 [USACO 2009 Mar S]Look Up
MySQL advanced learning notes (4)
秒杀系统设计
Multiprocess programming (I): basic concepts
Using tensorflow to realize voiceprint recognition
Pageoffice - bug modification journey
JSON conversion tool class
Multiprocess programming (II): Pipeline
Leetcode skimming - game 280
setInterval定时器在ie不生效原因之一:回调的是箭头函数
Chapter 3 of getting started with MySQL: database creation and operation
Andorid gets the system title bar height
NC24840 [USACO 2009 Mar S]Look Up
FAQ | FAQ for building applications for large screen devices
Install docker and use docker to install MySQL
130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
JSON转换工具类
form表单实例化
[shutter] open the third-party shutter project
Briefly talk about other uses of operation and maintenance monitoring