[slf4j-dev] Static binding...

Ceki Gülcü ceki at qos.ch
Thu Nov 26 17:55:45 CET 2009


Hi Joern,

Well, it's more of a java question than slf4j. The difference is between 
direct method call and a method call via reflection. The latter is known 
to be a bit slower and is also harder to read. There might also be 
subtle class loader differences.

Joern Huxhorn wrote:
> I was wondering if there is a real substantial difference between
> 
> a) ILoggerFactory 
> factory=org.slf4j.impl.StaticLoggerBinder.getLoggerFactory();
> 
> and
> 
> b) ILoggerFactory factory=(ILoggerFactory) 
> Class.forName("org.slf4j.impl.StaticLoggerBinder").getMethod("getLoggerFactory").invoke(null); 
> 
> 
> I mean, are the classes resolved any different?
> 
> Beside a compile-time error in case of a) if the class is missing, of 
> course.
> 
> Regards,
> Joern.

--
Ceki


More information about the slf4j-dev mailing list