Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the latest options in Java logging frameworks? [closed]

This question gets asked periodically, but I've long felt that existing Java logging frameworks were overcomplicated and over-engineered, and I want to see what's new.

I have a more critical issue on my current project as we've standardized on JSON as our human-readable data encoding, and most logging frameworks I've seen require XML. I would really rather avoid using JSON for 95% of my apps configuration, and XML for the rest just because of the logging framework (truth be told, I hate XML used for anything other than text markup, its original intended purpose).

Are there any hot new Java logging frameworks that are actively maintained, reasonably powerful, have a maven repo, can be reconfigured without restarting your app, and don't tie you to XML?

like image 325
sanity Avatar asked Mar 28 '10 16:03

sanity


People also ask

Which logging framework 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.

Which is better Log4j2 or Logback?

I recommend using Log4j2 because it's the fastest and most advanced of the three frameworks. Logback is still a good option, if performance is not your highest priority. Stackify's Application Performance Management tool, Retrace offers log management for your Java applications.

Is Log4j and SLF4J same?

SLF4J and Log4J are different, or they are not similar components. As the name specified, SLF4J is a simple logging façade for java. It is not a logging component, and even it does not do the actual logging. It is only an abstraction layer to an underlying logging component.

How many types of logs are there in Java?

Logging is an important topic in software development, especially if you need to analyze bugs and other unexpected events in your production environment.


1 Answers

You have 3 options:

  • Log4J
  • java.util.logging (JUL)
  • Logback (the successor of Log4J)

Now, let's see how they meet your requirements:

  1. actively maintained
  2. reasonably powerful
  3. have a maven repo
  4. can be reconfigured without restarting your app
  5. don't tie you to XML

log4j:

  1. No, not actively maintained
  2. Yes -
  3. Yes -
  4. Yes -
  5. Yes (using Java properties file, see Configuration).

java.util.logging (JUL):

  1. I'd say Yes -
  2. at your discretion -
  3. N/A -
  4. Yes (via JMX or LogManager#readConfiguration() -
  5. Yes (using properties files)

Logback:

  1. Yes -
  2. Yes -
  3. Yes -
  4. Yes, via JMX or autoScan -
  5. Configuration files in XML or Groovy

It looks like you'll have to make some concessions (or find a framework I'm not aware of). I would go for Logback, this is where things happen now.

like image 160
Pascal Thivent Avatar answered Sep 20 '22 01:09

Pascal Thivent