How to learn how to use slf4j?

Today I asked a question about log4j and said that it is now "deprecated" and that I should use slf4j and logback. So now I will use it, but I do not understand where to start? slf4j is the level of abstraction over other posting frameworks after what i read but i can't find anything but a really basic hello world logging tutorial? How to configure slf4j and use it?

+4
source share
2 answers

Slf4j is an API, and yes, perhaps an edge is probably the implementation you want. Just use the slf4j logger classes in your code and add logback.jar and logback.xml to your classpath. On the main page of the magazine contains a lot of information necessary to get started.

+4
source

You will use slf4j with log4j (or any other logging implementation). Therefore, if you use log4j with slf4j, you will need to provide the log4j configuration in log4j.properties. Thus, the advantage is that if you want to switch to Logback later, you just need to replace the jar binding file (for log4j it could be slf4j-log4j12-1.6.6.jar ) with a new binding bank and add the configuration for Logback. No code change.

This thread should help you.
SLF4J Manual

+3
source

Source: https://habr.com/ru/post/1433143/


All Articles