当前位置:网站首页>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
边栏推荐
- IP home online query platform
- Jeecg request URL signature
- 萬卷書 - 價值投資者指南 [The Education of a Value Investor]
- La différence entre le let Typescript et le Var
- Topic | synchronous asynchronous
- Discussion on some problems of array
- Common analysis with criteria method
- [solved] win10 cannot find a solution to the local group policy editor
- VMware virtual machine installation
- Advanced API (multithreading)
猜你喜欢

Circuit, packet and message exchange

Common problems in io streams

Store WordPress media content on 4everland to complete decentralized storage

Interfaces and related concepts

JUC forkjoinpool branch merge framework - work theft

c语言指针的概念

Basic knowledge about SQL database

691. 立方体IV
![PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef](/img/65/1f28071fc15e76abb37f1b128e1d90.jpg)
PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef

【开发笔记】基于机智云4G转接板GC211的设备上云APP控制
随机推荐
C WinForm framework
7.2 brush two questions
URL programming
20220319
Resthighlevelclient gets the mapping of an index
论文学习——鄱阳湖星子站水位时间序列相似度研究
Advanced API (use of file class)
Longest common prefix and
带你全流程,全方位的了解属于测试的软件事故
Some basic operations of reflection
691. Cube IV
Common problems in io streams
Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS
为什么说数据服务化是下一代数据中台的方向?
LeetCode
Specified interval inversion in the linked list
The education of a value investor
Arduino Serial系列函数 有关print read 的总结
Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
Laravel Web Framework