当前位置:网站首页>日志@Slf4j介绍使用及配置等级
日志@Slf4j介绍使用及配置等级
2022-08-10 12:52:00 【李长渊哦】
一、依赖及插件
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
安装一个lombok插件
二、设置日志级别
日志级别从小到大为 trace < debug < info < warn < error < fatal,由于默认日志级别设置为 INFO,因此info级别的日志时, trace 和 debug 级别的日志都看不到。
我们可以在 applicaition.yml文件中修改日志级别。比如将全局日志级别都改成 trace,则系统所有的日志都能看到
logging:
level:
com.example.demo: trace #com.example.demo为包名
三、演示
@Slf4j
@RestController
public class LogController {
@ApiOperation("测试日志")
@GetMapping("/LogTest")
public People queryList() {
People people = new People(1, "小王", 1);
log.error(people.toString());
log.warn(people.toString());
log.info(people.toString());
//比如将全局日志级别都改成 trace,则系统所有的日志都能看到。
log.debug(people.toString());
log.trace(people.toString());
return people;
}
}

边栏推荐
猜你喜欢

M²BEV: Multi-Camera Joint 3D Detection and Segmentation with Unified Bird’s-Eye View Representation

Code Casual Recording Notes_Dynamic Programming_70 Climbing Stairs

Short read or OOM loading DB. Unrecoverable error, aborting now

生成树协议STP(Spanning Tree Protocol)

Nanodlp v2.2/v3.0光固化电路板,机械开关/光电开关/接近开关的接法和系统状态电平设置

LeetCode中等题之搜索二维矩阵

A unit test report for CRM One Order Application log

2022 Recruitment Notice for Academician Zhao Guoping Group of Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences

跨域的五种解决方案

Jiugongge lottery animation
随机推荐
ABAP 里文件操作涉及到中文字符集的问题和解决方案试读版
M²BEV: Multi-Camera Joint 3D Detection and Segmentation with Unified Bird’s-Eye View Representation
wirshark 常用操作及 tcp 三次握手过程实例分析
Overview of Loudi Petrochemical Experiment Design and Construction Planning
the height of the landscape
Drive IT Modernization with Low Code
Jenkins修改默认主目录
Blast!ByteDance successfully landed, only because the interview questions of LeetCode algorithm were exhausted
Prada, big show?In the yuan in the universe that!
Digicert EV证书签名后出现“证书对于请求用法无效”的解决方案
Have you guys encountered this problem?MySQL 2.2 and 2.3-SNAPSHOT are like this, it seems to be
海外邮件发送指南(二)
Codeforces Round #276 (Div. 1) D. Kindergarten
Fragment's show and hide
WebView的优化与常见问题解决方案
Reversing words in a string in LeetCode
11+ chrome高级调试技巧,学会效率直接提升666%
【学习笔记】Redis的持久化
ArcMAP出现-15的问题无法访问[Provide your license server administrator with the following information:Err-15]
Network Saboteur