[slf4j-dev] [Bug 163] Copy & paste of LoggerFactory.getLogger

bugzilla-daemon at pixie.qos.ch bugzilla-daemon at pixie.qos.ch
Fri Dec 11 10:22:59 CET 2009


http://bugzilla.slf4j.org/show_bug.cgi?id=163





--- Comment #7 from Joern Huxhorn <joern at huxhorn.de>  2009-12-11 10:22:59 ---
--- file A.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class A {
  void foo() {
    Logger logger = LoggerFactory.getLogger(A.class);
    logger.info("foo");
  }
}

-- file B.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class B extends A {
  void bar() {
    Logger logger = LoggerFactory.getLogger(B.class);
    logger.info("bar");
  }
}

would print
2009-12-11 08:44:22,145  INFO [main] [] A - foo
2009-12-11 08:44:22,160  INFO [main] [] A - foo
2009-12-11 08:44:22,160  INFO [main] [] B - bar
instead.

This is, in my opinion, better style as the code that prints "foo" is actually
located in A, not B. Neither technique is wrong I just think that the result of
using XYZ.class is more intuitive.

Wow, you nearly had me there, I'm also in need of coffee!


-- 
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the slf4j-dev mailing list