Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Java 1.5 varargs API for slf4j yet?

Tags:

I want to get rid of this lot...

public void info(String msg); public void info(String format, Object arg); public void info(String format, Object arg1, Object arg2); public void info(String format, Object[] argArray); 

...and replace it with this one...

public void info(String format, Object ... args); 

...so that my logging syntax doesn't have to change depending on the number of arguments I want to log. There seems to be lots of discussion and work around it, but where is it? Or should I wrap the wrapper that is slf4j?

like image 557
Josh Avatar asked Dec 23 '09 13:12

Josh


People also ask

What is SLF4J API?

SLF4J stands for Simple Logging Facade for Java. It provides a simple abstraction of all the logging frameworks. It enables a user to work with any of the logging frameworks such as Log4j, Logback, JUL (java. util.

How do I know what SLF4J I have?

Easy. Put a breakpoint on .. say.. LOG.info(...). Once debugger stops there, step into.. and viola.. you will find yourself in the code of the actual logger...

How do I turn off Info logs in SLF4J?

To disable this behavior, you must add a logback configuration file called logback. xml in your java classpath root. You can download this minimal logback. xml file and add it in the src/main/resources directory for a maven project or beside fr directory for a simple java project.

What is the use of SLF4J in Java?

What Is SLF4J. The SLF4J or the Simple Logging Facade for Java is an abstraction layer for various Java logging frameworks, like Log4j 2 or Logback. This allows for plugging different logging frameworks at deployment time without the need for code changes.


1 Answers

The real question is "Why must a jdk < 5 be supported by this any longer"? If you have an older version of java, then use the older API. It's that simple. Why not make this fit better into the current java world? I mean, JDK 5 isn't even supported without a support contract from Sun/Oracle. Backward compatibility is a joke in this case.

like image 191
Briggs Avatar answered Sep 21 '22 19:09

Briggs