Why is Logback the default logging framework in Spring Boot? [closed]
Asked Answered
Q

2

27

I've tried to search on Spring documentation + articles on the internet + questions from Stackoverflow but I didn't find any information about it. For me the configuration of Log4J2 (especially the pattern) is much simpler, personal taste.

Also, I find that Log4J2 has better performance than Logback according to these articles:

https://stackify.com/compare-java-logging-frameworks

https://blog.overops.com/the-logging-olympics-a-race-between-todays-top-5-logging-frameworks

What is the difference between log4j, slf4j and logback?

https://www.sitepoint.com/which-java-logging-framework-has-the-best-performance/

And if we are to consider Async Logger, the performance is expediently higher in favor of Log4J2 according to Apache - https://logging.apache.org/log4j/2.x/performance.html and yes I know that it's their job to make their framework look better but I do believe that they are reliable.

My assumption is that Pivotal choose Logback to be the default because Log4J2 came sometime after they released version 1.0 of Spring-Boot.

Can anyone shed some light on this? Is my assumption correct?

Questa answered 15/4, 2019 at 7:46 Comment(1)
I think you have to ask to the Spring Boot github. And please, report here the response :)Overmaster
O
21

This is the reason:

Phil Webb: I don't really feel like the arguments being made justify the introduction of a breaking change. [...] If we were starting Spring Boot today we may well have chosen Log4J2 over Logback, but I think so far there are no massively compelling reasons to cause our users upgrade pain. [...] I think it's unlikely that we'll consider switching the default logging system until the next major release of Spring Boot.

Ralph Goers: support for configuring Log4j 2 from Spring Cloud Config is planned to be added.

Source

Overmaster answered 7/7, 2019 at 16:35 Comment(1)
Phil Web is not directly answering my question in his response but it looks like my assumptions were right. The Spring team choose it because it was the best option when version 1.0.0 of Spring boot was released.Questa
H
3

Log4j 2.12.0 added support for utilizing Spring Cloud Config to host the Log4j configuration with dynamic reconfiguration and added support for Docker. With the release of Log4j 2.13.0 Log4j has further integrated with Spring by providing a Spring Lookup so the Log4j configuration can access spring properties. In addition, some Log4j system properties can also be read from Spring's bootstrap.yml or application.yml files. 2.13.0 also provides a Kubernetes Lookup to allow Kubernetes attributes to be specified in the Log4j configuration as properties to include in the log events.

See Logging in the Cloud and Log4j Spring Cloud Config Client.

Ha answered 2/11, 2019 at 5:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.