0
Follow
0
View

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:

<dependency>
    <groupId>org.projectlombokgroupId>
    <artifactId>lombokartifactId>
dependency>
Using

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

@Slf4j
class DemoApplicationTests {
@Test
public void test(){
log.debug("输出DEBUG日志.......");
}
}
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

我无法获得飞溅工作与新aduser使用给定和创建的属性

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

SwiftUI Picker标签与PickerStyle .menu在iOS HowTo

不同的java版本与sudo命令

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

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

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

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

从ReactDOM.render返回Object

windows服务从c#工作在本地,而不是在远程桌面