How do you use logging in your code?

dqj0618 注册会员
2023-01-24 22:10

There are actually two ways to do this.
The first is actually a way that was used a long time ago. You just need to add the following to the code:

private final Logger logger= LoggerFactory.getLogger(DemoApplicationTests.class)

This way is obviously more frivolous, if every class to add it is not very low.
A second
lombok solves this problem for us without having to write a single line of code for every class.
To use lombok, you need to add the following dependencies:


is also very simple. You just need to annotate the class with a comment @Slf4j as follows:

class DemoApplicationTests {
public void test(){
ddttjj123 注册会员
2023-01-24 22:10

logger4j is one of the most widely used logging libraries. I suggest you learn how to use it. You use it all the time. There's a lot of information on the Internet, Or I recommend to you: < a href = "https://blog.csdn.net/babdpfi/article/details/127350198" target="_blank"> https://blog.csdn.net/babdpfi/article/details/127350198

czyroy 注册会员
2023-01-24 22:10

Give it up!! May you come into a good fortune

About the Author

Question Info

Publish Time
2023-01-24 22:10
Update Time
2023-01-24 22:10

Related Question


生成不带CsProj的Dotnet GRPC客户端代码

SwiftUI Picker标签与PickerStyle .menu在iOS HowTo


findOneBy() -消毒电子邮件输入- mongodb-odm 2.x

electron+vue开发windows桌面端 ,获取串口列表

How to expand dataframe with a calculated list based on rows in python

Django: NoneType对象没有user属性错误