Java – is logback mature enough to replace log4j?

I have read similar questions, such as this and this But they're about four years old!

In addition, I also read the logback page of this, which contains some very good information to explain why I chose logback over log4j

I want to implement a logging framework for projects with the following technology stacks –

>Spring > sleep > Maven > Tomcat > rest

I have decided to use slf4j as the appearance, so the question is whether to use slf4j, log4j or slf4j logback (I know logback itself uses slf4j)

What I'm looking for is –

>Has anyone ever used logback to prove that it is not as mature or efficient as log4j? > How fair is it compared to log4j in a multithreaded environment? > Can replace Tomcat default Jul logging with logback / log4j logging > can merge logging configuration into the public file of Maven multi module project > logback claims that it is 10 times faster than log4j. Has anyone verified this claim? (as part of my research, I plan to run some tests to measure performance and send back my results)

Editor: I've read many places (one of the answers below also explains this) log4j is dead / abandoned In contrast, log4j has just released its 2.0 alpha version So I don't buy that argument

Solution

Logback successfully logs in to log4j. It comes from the author who made log4j Log4j is currently deprecated

The following is an example of slf4j / logback prime numbers:

Log4j (current)

Object entry = new SomeObject();
logger.debug("The new entry is "+entry+".");

The following tasks are performed:

>Java calls the toString method on a variable entry to get a string literal representation Java initializes the space in the heap to hold string objects. > Java creates a new string based on the above string, which contains "new entry" and "." Java initializes the space to save the updated string text. > Java passes the newly constructed string object as an input parameter to log4j Log4j check whether the current logging level is debug or above (assuming it is set to info in the logging.xml descriptor) > log4j will not print string text to the log because the logging level is set to info (therefore, all work on 1-2 is wasted)

Slf4j / logback (New)

Object entry = new SomeObject();
logger.debug("The new entry is {}.",entry);

The following tasks are performed:

>Java passes string object "new entry is {}." The object entry is passed to slf4j as an input parameter Slf4j checks whether the current logging level is debug or above (assuming it is set to info in the logging.xml descriptor) > log4j will not print string text to the log because the logging level is set to info

http://www.slf4j.org/faq.html#logging_performance

Can I replace the Tomcat default Jul log with logback / log4j loggin?

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>