当前位置:网站首页>logback配置文件
logback配置文件
2022-07-02 23:09:00 【Cold Snowflakes】
可以看到,导入了 web 依赖之后,其实内嵌的有日志模块了。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
解决在IDEA旗舰版中注入 DAO的时候报错,编辑 Inspection Setting,将 Severity由 Error 改为 Warning
pattern 参数
%c / class,输出执行记录请求的全限定名。尽量避免使用,除非执行速度不造成任何问题。
%F / file,输出执行记录请求的Java源文件名。尽量避免使用,除非执行速度不造成任何问题。
%L / line,输出执行日志请求的行号。尽量避免使用,除非执行速度不造成任何问题。
%m / msg / message,输出应用程序提供的信息。
%M / method,输出执行日志请求的方法名。尽量避免使用,除非执行速度不造成任何问题。
%r / relative,输出从程序启动到创建日志记录的时间,单位是毫秒。
可选的格式修饰符位于"%"和转换符之间
左对齐 标志,符号是减号 “-”;接着是可选的最小宽度,用十进制数表示。如果字符小于最小宽度,就进行填充。
最大宽度 修饰符,符号是点号 “.” 后面加十进制数。如果字符大于最大宽度,则从前面截断。点符号 “.” 后面加减号 “-” 在加数字,表示从尾部截断。
%-20.40c # 最小宽度20, 最大宽度40, 不够用就截断, 还剩的有就用空格填充, - 是 左对齐
一些参数
日志信息输出目的地
1.org.apache.log4j.ConsoleAppender(控制台)
2.FileAppender(文件)
3.DailyRollingFileAppender(每天产生一个日志文件)
4.RollingFileAppender(文件大小到达指定尺寸的时候产生一个新的文件)
5.WriterAppender(将日志信息以流格式发送到任意指定的地方)
日志信息的格式
1.org.apache.log4j.HTMLLayout(HTML表格形式布局)
2.PatternLayout(指定布局模式)
3.SimpleLayout(日志信息的级别和信息字符串)
4.TTCCLayout(日志产生的时间、线程、类别等信息)
我的配置
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 定义变量 -->
<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" />
<!-- 输出到控制台 -->
<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>
<!-- 生成日志文件 -->
<appender name="fileLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件的文件名及保存路径-->
<FileNamePattern>${LOG_PATH}/logback.%d{yyyy-MM-dd}.[%i].log</FileNamePattern>
<!--日志文件最大的大小-->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<MaxHistory>2</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 日志输出级别 -->
<!-- 至多只能配置一个root -->
<root level="info">
<appender-ref ref="Console" />
<appender-ref ref="fileLog" />
</root>
</configuration>
logback彩色日志配置以及banner启动设置
logback彩色字符编码
spring boot logback
logback.xml配置
logback官网配置
边栏推荐
- Form form instantiation
- Unique line of "Gelu"
- [shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)
- Practical series - free commercial video material library
- Is there a specific format for English papers?
- NC20806 区区区间间间
- maya渔屋建模
- Open source | Wenxin big model Ernie tiny lightweight technology, which is accurate and fast, and the effect is fully open
- Open Source | Wenxin Big Model Ernie Tiny Lightweight Technology, Accurate and Fast, full Open Effect
- pod生命周期详解
猜你喜欢
论文的英文文献在哪找(除了知网)?
Multiprocess programming (II): Pipeline
Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation
MySQL advanced learning notes (III)
In February 2022, the ranking list of domestic databases: oceanbase regained its popularity with "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
写论文可以去哪些网站搜索参考文献?
Markdown使用教程
How QT exports data to PDF files (qpdfwriter User Guide)
[shutter] open the third-party shutter project
130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
随机推荐
pageoffice-之bug修改之旅
Is there a specific format for English papers?
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
MySQL 23道经典面试吊打面试官
带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)
95 pages of smart education solutions 2022
Don't want teachers to see themselves with cameras in online classes? Virtual camera you deserve!
How to specify const array in the global scope of rust- How to specify const array in global scope in Rust?
秒杀系统设计
[reading notes] phased summary of writing reading notes
多进程编程(二):管道
The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
Monitor container runtime tool Falco
helm 基础学习
What are the recommended thesis translation software?
英文论文有具体的格式吗?
Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation
Slf4j + Logback日志框架
Slf4j + logback logging framework
Architecture: database architecture design