0

Why does org.slf4j.Logger use varargs like:

public void info(Marker marker, String format, Object... arguments);

But both org.slf4j.ext.LoggerWrapper and thus org.slf4j.cal10n.LocLogger use Arrays like:

public void info(Marker marker, String format, Object[] argArray);
DarVar
  • 16,882
  • 29
  • 97
  • 146

1 Answers1

1

LoggerWrapper and LocLogger are compatible with varargs syntax when Java 5+ is used, but they are also compatible with Java < 5. The array syntax can be compiled and run under older versions of Java while still supporting varargs syntax when Java >= 5 is used.

The SLF4J API < 1.7 used array syntax. With API version 1.7, the varargs syntax was used, which means it cannot be used on Java versions < 5.

You might have a look at varargs and the '...' argument for some more examples of how this works and why you might want to do it.

Community
  • 1
  • 1
ngreen
  • 1,559
  • 13
  • 22