当前位置:网站首页>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
边栏推荐
- Multiprocess programming (II): Pipeline
- One of the reasons why setinterval timer does not take effect in ie: the callback is the arrow function
- [shutter] Introduction to the official example of shutter Gallery (learning example | email application | retail application | wealth management application | travel application | news application | a
- [golang syntax] map common errors golang panic: assignment to entry in nil map
- Confluence的PDF导出中文文档异常显示问题解决
- Using tensorflow to realize voiceprint recognition
- Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation
- Question e: merged fruit -noip2004tgt2
- Basic use of shell script
- 多进程编程(三):消息队列
猜你喜欢
![Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation](/img/4a/ab732c41ea8a939fa0983fec475622.png)
Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation

CMake基本使用

University of Toronto:Anthony Coache | 深度强化学习的条件可诱导动态风险度量

Custom throttling function six steps to deal with complex requirements

Talk with the interviewer about the pit of MySQL sorting (including: duplicate data problem in order by limit page)

setInterval定时器在ie不生效原因之一:回调的是箭头函数

Which software can translate an English paper in its entirety?

来自数砖大佬的 130页 PPT 深入介绍 Apache Spark 3.2 & 3.3 新功能

为什么网站打开速度慢?

【雅思阅读】王希伟阅读P1(阅读判断题)
随机推荐
What is the standard format of a 2000-3000 word essay for college students' classroom homework?
多进程编程(二):管道
Is there a specific format for English papers?
What are the recommended thesis translation software?
Multi process programming (III): message queue
Leetcode skimming - game 280
Is the multitasking loss in pytoch added up or backward separately?
Implement the foreach method of array
字符设备注册常用的两种方法和步骤
详解用OpenCV的轮廓检测函数findContours()得到的轮廓拓扑结构(hiararchy)矩阵的意义、以及怎样用轮廓拓扑结构矩阵绘制轮廓拓扑结构图
One of the reasons why setinterval timer does not take effect in ie: the callback is the arrow function
哪些软件可以整篇翻译英文论文?
来自数砖大佬的 130页 PPT 深入介绍 Apache Spark 3.2 & 3.3 新功能
NC24840 [USACO 2009 Mar S]Look Up
Redis21 classic interview questions, extreme pull interviewer
Confluence的PDF导出中文文档异常显示问题解决
The most painful programming problem in 2021, adventure of code 2021 Day24
zhvoice
在线预览Word文档
Architecture: load balancing