You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Adam Crain <ac...@greenenergycorp.com> on 2011/02/25 15:53:52 UTC

file/method/class location information

Hi,

Would someone point me to where log4j determines call location info? I'm
expecting to find something like:

Thread.currentThread().getStackTrace()[2].getLineNumber()


Is the place in the callstack configurable? I'm trying to write a Scala
wrapper to SLF4J that uses a Log4j backend, and I'd like to shift the
localization when level up in the callstack.

best,
Adam

-- 

*Adam Crain*

Chief Platform Architect, GEC

Office: 919.836.9916

Cell:  919.428.1002

acrain@greenenergycorp.com <ab...@greenenergycorp.com>


*Green Energy Corp,* *enabling the smart grid of the future.**   *

*www.greenenergycorp.com*

*www.totalgrid.org*

Re: file/method/class location information

Posted by John W Hiltenbrand <jh...@us.ibm.com>.
Adam,
   Take a look at how Logger's info/warn/debug/error methods call forcedLog
passing a FQCN (fully qualified class name).  This is passed into the
LoggingEvent and in turn to LocationInfo.  The magic of the stack trace
read is done in the constructor.  I've successfully moved the entry point
up the stack trace by passing a different FQCN to the generic method:
 public void log(String callerFQCN, Priority level, Object message,
Throwable t)
In this sense, I suppose that the place in the callstack is configurable.

Hope this helps.

Sincerely,
John Hiltenbrand



From:	Adam Crain <ac...@greenenergycorp.com>
To:	log4j-user@logging.apache.org
Date:	02/25/2011 08:57 AM
Subject:	file/method/class location information



Hi,

Would someone point me to where log4j determines call location info? I'm
expecting to find something like:

Thread.currentThread().getStackTrace()[2].getLineNumber()


Is the place in the callstack configurable? I'm trying to write a Scala
wrapper to SLF4J that uses a Log4j backend, and I'd like to shift the
localization when level up in the callstack.

best,
Adam

--

*Adam Crain*

Chief Platform Architect, GEC

Office: 919.836.9916

Cell:  919.428.1002

acrain@greenenergycorp.com <ab...@greenenergycorp.com>


*Green Energy Corp,* *enabling the smart grid of the future.**   *

*www.greenenergycorp.com*

*www.totalgrid.org*