当前位置:网站首页>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
边栏推荐
- Take you through the whole process and comprehensively understand the software accidents that belong to testing
- 691. Cube IV
- C code production YUV420 planar format file
- How to specify the execution order for multiple global exception handling classes
- [set theory] partition (partition | partition example | partition and equivalence relationship)
- II. D3.js draw a simple figure -- circle
- Chrome 98 Private Network Access problem w/ disabled web security: Request had no target IP address
- Laravel frame step pit (I)
- [Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
- 萬卷書 - 價值投資者指南 [The Education of a Value Investor]
猜你喜欢
Docker builds MySQL: the specified path of version 5.7 cannot be mounted.
【已解决】Unknown error 1146
Arduino Serial系列函数 有关print read 的总结
7.2 brush two questions
C code production YUV420 planar format file
Distributed transactions
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
Map interface and method
Hash table, generic
最全SQL与NoSQL优缺点对比
随机推荐
你开发数据API最快多长时间?我1分钟就足够了
Download address collection of various versions of devaexpress
twenty million two hundred and twenty thousand three hundred and nineteen
TCP cumulative acknowledgement and window value update
Topic | synchronous asynchronous
萬卷書 - 價值投資者指南 [The Education of a Value Investor]
URL programming
论文学习——鄱阳湖星子站水位时间序列相似度研究
《指环王:力量之戒》新剧照 力量之戒铸造者亮相
万卷书 - 价值投资者指南 [The Education of a Value Investor]
Wireshark software usage
带你全流程,全方位的了解属于测试的软件事故
IP home online query platform
Summary of Arduino serial functions related to print read
[HCAI] learning summary OSI model
TreeMap
When MySQL inserts Chinese into the database, there is a diamond question mark garbled code
Longest common prefix and
【已解决】win10找不到本地组策略编辑器解决方法
[most detailed] latest and complete redis interview book (50)