当前位置:网站首页>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
边栏推荐
- Common problems in io streams
- docket
- The difference between typescript let and VaR
- Use of generics
- Book recommendation~
- How to specify the execution order for multiple global exception handling classes
- The underlying mechanism of advertising on websites
- C代码生产YUV420 planar格式文件
- Arduino Serial系列函数 有关print read 的总结
- Common methods of file class
猜你喜欢
IP home online query platform
Interfaces and related concepts
Margin left: -100% understanding in the Grail layout
Custom generic structure
Topic | synchronous asynchronous
Map interface and method
Leetcode 198: 打家劫舍
New stills of Lord of the rings: the ring of strength: the caster of the ring of strength appears
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
691. Cube IV
随机推荐
[plus de détails] dernière entrevue complète redis (50)
IO stream system and FileReader, filewriter
VMWare网络模式-桥接,Host-Only,NAT网络
高并发内存池
SharePoint modification usage analysis report is more than 30 days
Distributed transactions
【无标题】
Common operations of JSP
Common APIs
[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
C WinForm framework
Talk about floating
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
Jeecg data button permission settings
Interfaces and related concepts
C代码生产YUV420 planar格式文件
FileInputStream and fileoutputstream
2021-07-18
《指環王:力量之戒》新劇照 力量之戒鑄造者亮相
691. 立方体IV