logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John W Hiltenbrand <jhilt...@us.ibm.com>
Subject Re: file/method/class location information
Date Fri, 25 Feb 2011 22:29:26 GMT

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 <acrain@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 <abender@greenenergycorp.com>


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

*www.greenenergycorp.com*

*www.totalgrid.org*

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message