当前位置:网站首页>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
边栏推荐
- VMWare网络模式-桥接,Host-Only,NAT网络
- [Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
- Take you through the whole process and comprehensively understand the software accidents that belong to testing
- "Moss ma not found" solution
- Advanced API (multithreading)
- Some experiences of Arduino soft serial port communication
- TreeMap
- Summary of Arduino serial functions related to print read
- [set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)
- VMware virtual machine installation
猜你喜欢

Common methods of file class

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

3311. Longest arithmetic

Custom generic structure

专题 | 同步 异步

TreeMap

Introduction of buffer flow

Margin left: -100% understanding in the Grail layout

高并发内存池
![[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet](/img/9d/42dfef67246740f0dba0c6d8f1b625.jpg)
[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
随机推荐
在 4EVERLAND 上存储 WordPress 媒体内容,完成去中心化存储
Leetcode 198: 打家劫舍
Win 2008 R2 crashed at the final installation stage
How to specify the execution order for multiple global exception handling classes
4279. Cartesian tree
JS monitors empty objects and empty references
最全SQL与NoSQL优缺点对比
Topic | synchronous asynchronous
树莓派更新工具链
TreeMap
[plus de détails] dernière entrevue complète redis (50)
Crontab scheduled task
深度学习参数初始化(一)Xavier初始化 含代码
Hash table, generic
[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
Advanced API (local simulation download file)
Advanced API (batch image Download & socket dialog)
20220319
Selenium key knowledge explanation