You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2013/06/14 14:57:40 UTC
org.apache.logging.log4j.spi.AbstractLogger.FQCN
Hi All:
Why is org.apache.logging.log4j.spi.AbstractLogger.FQCN defined as:
private static final String FQCN = AbstractLogger.class.getName();
instead of:
private final String FQCN = this.getClass().getName();
Gary
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: org.apache.logging.log4j.spi.AbstractLogger.FQCN
Posted by Gary Gregory <ga...@gmail.com>.
On Fri, Jun 14, 2013 at 9:20 AM, Ralph Goers <ra...@dslextreme.com>wrote:
> Because this.getClass().getName() doesn't work.
>
> When searching for the class in the stack AbstractLogger is what will show
> up since that is where the method is defined.
>
Uh, no, getClass() returns the class of the receiving object, not the class
of where it is compiled.
Gary
>
> Ralph
>
> On Jun 14, 2013, at 5:57 AM, Gary Gregory wrote:
>
> Hi All:
>
> Why is org.apache.logging.log4j.spi.AbstractLogger.FQCN defined as:
>
> private static final String FQCN = AbstractLogger.class.getName();
>
> instead of:
>
> private final String FQCN = this.getClass().getName();
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: org.apache.logging.log4j.spi.AbstractLogger.FQCN
Posted by Gary Gregory <ga...@gmail.com>.
On Fri, Jun 14, 2013 at 9:27 AM, Nick Williams <
nicholas@nicholaswilliams.net> wrote:
> Yea. If a class that extends AbstractLogger calls the logging method that
> takes the FQCN (for example, overrides a "debug" method), it needs to use
> its /own/ private static FQCN variable. But the AbstractLogger needs one
> that is AbstractLogger instead of the implementing class.
>
Well, is this Javadoc in
org.apache.logging.log4j.spi.AbstractLogger.log(Marker, String, Level,
Message, Throwable) wrong then?
/**
* Logs a message with location information.
*
* @param marker The Marker
* @param fqcn The fully qualified class name of the <b>caller</b>
* @param level The logging level
* @param data The Message.
* @param t A Throwable or null.
*/
protected abstract void log(Marker marker, String fqcn, Level level,
Message data, Throwable t);
If fqcn is always org.apache.logging.log4j.spi.AbstractLogger, then it is
NOT the "The fully qualified class name of the <b>caller</b>."
Gary
>
> On Jun 14, 2013, at 8:20 AM, Ralph Goers wrote:
>
> Because this.getClass().getName() doesn't work.
>
> When searching for the class in the stack AbstractLogger is what will show
> up since that is where the method is defined.
>
> Ralph
>
> On Jun 14, 2013, at 5:57 AM, Gary Gregory wrote:
>
> Hi All:
>
> Why is org.apache.logging.log4j.spi.AbstractLogger.FQCN defined as:
>
> private static final String FQCN = AbstractLogger.class.getName();
>
> instead of:
>
> private final String FQCN = this.getClass().getName();
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: org.apache.logging.log4j.spi.AbstractLogger.FQCN
Posted by Nick Williams <ni...@nicholaswilliams.net>.
Yea. If a class that extends AbstractLogger calls the logging method that takes the FQCN (for example, overrides a "debug" method), it needs to use its /own/ private static FQCN variable. But the AbstractLogger needs one that is AbstractLogger instead of the implementing class.
On Jun 14, 2013, at 8:20 AM, Ralph Goers wrote:
> Because this.getClass().getName() doesn't work.
>
> When searching for the class in the stack AbstractLogger is what will show up since that is where the method is defined.
>
> Ralph
>
> On Jun 14, 2013, at 5:57 AM, Gary Gregory wrote:
>
>> Hi All:
>>
>> Why is org.apache.logging.log4j.spi.AbstractLogger.FQCN defined as:
>>
>> private static final String FQCN = AbstractLogger.class.getName();
>>
>> instead of:
>>
>> private final String FQCN = this.getClass().getName();
>>
>> Gary
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> JUnit in Action, Second Edition
>> Spring Batch in Action
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>
Re: org.apache.logging.log4j.spi.AbstractLogger.FQCN
Posted by Ralph Goers <ra...@dslextreme.com>.
Because this.getClass().getName() doesn't work.
When searching for the class in the stack AbstractLogger is what will show up since that is where the method is defined.
Ralph
On Jun 14, 2013, at 5:57 AM, Gary Gregory wrote:
> Hi All:
>
> Why is org.apache.logging.log4j.spi.AbstractLogger.FQCN defined as:
>
> private static final String FQCN = AbstractLogger.class.getName();
>
> instead of:
>
> private final String FQCN = this.getClass().getName();
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory