Logging with Project Lombok

Normally, when we use a Logging framework like Log4J, Logback or Simple Logging Facade for Java (SLF4J) for these Logging frameworks in a class, we need declare for example as below:

But with Project Lombok, we don’t need to do that.

When using Project Lombok, we only need declare an annotation for using a Logging framework, then we can use this Logging framework as usual. For example, I can declare @Slf4j annotation for using Simple Logging Facade for Java in my example as below:

In this case, if you check the /target/classes/com/huongdanjava/lombok/Example.class, you will see the content of Example class as below:

Obviously, you can see Project Lombok will generate the code to declare Logger object in class Example automatically.

Below is some others annotation for other Logging frameworks:

Logging with Project Lombok
Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
Facebook
2Share on Google+
Google+
0Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.