[slf4j-dev] [Bug 163] Copy & paste of LoggerFactory.getLogger
bugzilla-daemon at pixie.qos.ch
bugzilla-daemon at pixie.qos.ch
Fri Dec 11 08:10:08 CET 2009
http://bugzilla.slf4j.org/show_bug.cgi?id=163
--- Comment #5 from Joern Huxhorn <joern at huxhorn.de> 2009-12-11 08:10:07 ---
Well, that's really unfortunate. I didn't remember the optionality of the
stacktrace myself... Good catch, Ceki.
Concerning getClass() vs TheClass.class:
This has an entirely different behavior in case of inheritance.
class A
{
void foo()
{
logger.debug("foo");
}
}
class B extends A
{
void bar()
{
foo();
logger.debug("bar");
}
}
If class A and class B would obtain their logger using getLogger(A.class) and
getLogger(B.class) then they would log like this when bar() is called:
DEBUG - A - foo
DEBUG - B - bar
If they used getLogger(getClass()) instead, the log events would look like
this:
DEBUG - B - foo
DEBUG - B - bar
Further, configuring the level of the A logger would only have an effect on
instances of A, not on instances of B. Calling a.foo() behave differently than
calling b.foo().
I'd expect a message like
DEBUG - B - foo
to originate from class B and would be confused to find the actual call in
class A.
I've also created myself an IDEA LiveTemplate for the creation of Logger
instances ;)
--
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