Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended logger for use with Java, Hibernate and Spring [closed]

My web application is using Java, Hibernate's JPA implementation (EntityManager) and Spring. What are my logger choices and what would you recommend. Ideally the configuration would be simple (one config file for Hibernate, Spring and my code).

like image 606
Steve Kuo Avatar asked Jun 02 '09 18:06

Steve Kuo


People also ask

Which logger is best for spring boot?

If you are using Spring Boot Starters, Logback will provide a good support for logging. Besides, Logback also provides a use of good support for Common Logging, Util Logging, Log4J, and SLF4J.

What logger does Hibernate use?

Hibernate utilizes Simple Logging Facade for Java (SLF4J) in order to log various system events. SLF4J can direct your logging output to several logging frameworks (NOP, Simple, log4j version 1.2, JDK 1.4 logging, JCL or logback) depending on your chosen binding.

Which logger is best for Java?

One of the most popular solutions for the Java world is the Apache Log4j 2 framework. Maintained by the Apache Foundation, Log4j 2 is an improvement on the original Log4j, which was the most popular logging framework in Java for many years.

Does Hibernate use Log4j?

We do use Log4j during development of the Hibernate libraries as it's a dependency of our testsuites; therefore we've still upgraded all branches. These test dependencies won't be included in your application if you depend on the Hibernate libraries. The upgraded versions of each project are: Hibernate ORM: 5.3.


1 Answers

When building applications out of various frameworks you often need to wrap existing loggers, be they log4j or JUL or JULI or whatever. The standard application for this is the Simple Logging Facade for Java (SLF4J). Even if your app doesn't need SLF4J now you may later want to add a library that does need it, and it's your best hope for one config file in the long run.

With that in mind you should stick to logging packages that SLF4J supports, but usually it boils down to java.util.logging (JUL) or Apache's log4j. This has been a subject for debate for some time and you can find many opinions on both sides.

Personally, I think it's unfortunate that Java logging is in this situation, and I'll use whatever gives me the least pain for the situation.

like image 129
Glenn Avatar answered Oct 11 '22 14:10

Glenn