M
M
MaxLich2017-10-27 15:40:02
Java
MaxLich, 2017-10-27 15:40:02

Which Java logger to use in 2017?

Hello. It is necessary to fasten logging to the application in Java. Before that, I did not deal with logging in Java. I read articles about it, but these articles were old. It talked about the standard logger in Java, about slf4j and about log4j. A senior friend at work suggested log4j. So I look in his direction. But as I understand it, everything was muddy with its versions before: there was an old one, but stable, and there were two new versions, but unstable. Now I went to the Apache site to download the logger: the latest version is 2.9. Those articles said that 1.2 is an old but stable version, while versions 1.3 and 2.0 are unstable. This is version 2, so I don't know how stable it is. Download it or look for version 1.2?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
protven, 2017-10-27
@protven

slf4j is not a logger, but an api for loggers, a wrapper over them. I would recommend slf4j + logback. We use, in my opinion, the de facto standard now.

E
Evgeny Kornachev, 2017-10-27
@zelan

It is important to use slf4j+LOGGER, where LOGGER is a logger for which a link to slf4j is supported. Of these loggers, I can only recommend log4j and logback. I myself use the second one.
When using slf4j, you can GENERALLY abstract from the type of logger you are using. Thus, at any time you can switch from logback to any other. slf4j also allows you to 'redirect' logger messages from linked libraries to the main application logger. So, for example, you connected to your application a library in which log4j is already built in, and you use logback in your application. By connecting the "slf4j-log4j adapter" all messages from the connected library will go to slf4j, and then to your logback.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question