当前位置:网站首页>Lombok cooperates with @slf4j and logback to realize logging
Lombok cooperates with @slf4j and logback to realize logging
2022-07-03 07:24:00 【Maple Leaf pear flower】
Lombok coordination @Slf4j、Logback Implement logging
Development process , Need to use lombok, But sometimes it is not used SpringBoot frame , Therefore, the log is not automatically imported Jar, Need to be on your own maven Introduction in .
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.6</version>
</dependency>
Introduce the above jar package , And in resources Create below logback.xml
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
Can be introduced in the class @Slf4j
test
package com.plf.agent;
import lombok.extern.slf4j.Slf4j;
/**
* @author panlf
* @date 2021/11/10
*/
@Slf4j
public class HelloWorld {
public static void main(String[] args) {
log.info("Hello World");
}
}
// result
//2021-11-10 16:16:09.092 [main] INFO com.plf.agent.HelloWorld - Hello World
边栏推荐
- Thoughts on project development
- When MySQL inserts Chinese into the database, there is a diamond question mark garbled code
- 4EVERLAND:IPFS 上的 Web3 开发者中心,部署了超过 30,000 个 Dapp!
- C代码生产YUV420 planar格式文件
- Le Seigneur des anneaux: l'anneau du pouvoir
- JS monitors empty objects and empty references
- “百度杯”CTF比赛 2017 二月场,Web:爆破-1
- How to specify the execution order for multiple global exception handling classes
- Summary of Arduino serial functions related to print read
- LeetCode
猜你喜欢

Discussion on some problems of array

Common architectures of IO streams

Dora (discover offer request recognition) process of obtaining IP address

Selenium key knowledge explanation

Wireshark software usage

JUC forkjoinpool branch merge framework - work theft

C代码生产YUV420 planar格式文件

File operation serialization recursive copy

TCP cumulative acknowledgement and window value update

深度学习参数初始化(一)Xavier初始化 含代码
随机推荐
URL programming
TypeScript let与var的区别
Common methods of file class
Distributed transactions
High concurrency memory pool
【已解决】SQLException: Invalid value for getInt() - ‘田鹏‘
SecureCRT password to cancel session recording
[plus de détails] dernière entrevue complète redis (50)
2. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
Arduino 软串口通信 的几点体会
Spa single page application
Summary of abnormal mechanism of interview
Use of generics
萬卷書 - 價值投資者指南 [The Education of a Value Investor]
【CMake】CMake链接SQLite库
When MySQL inserts Chinese into the database, there is a diamond question mark garbled code
4EVERLAND:IPFS 上的 Web3 开发者中心,部署了超过 30,000 个 Dapp!
Sorting, dichotomy
New stills of Lord of the rings: the ring of strength: the caster of the ring of strength appears
Advanced API (UDP connection & map set & collection set)