org.apache.log4j.spi

Class LocationInfo

public class LocationInfo extends Object implements Serializable

The internal representation of caller location information.

Since: 0.8.3

Field Summary
StringfullInfo
All available caller information, in the format fully.qualified.classname.of.caller.methodName(Filename.java:line)
static StringNA
When location information is not available the constant NA is returned.
Constructor Summary
LocationInfo(Throwable t, String fqnOfCallingClass)
Instantiate location information based on a Throwable.
Method Summary
StringgetClassName()
Return the fully qualified class name of the caller making the logging request.
StringgetFileName()
Return the file name of the caller.
StringgetLineNumber()
Returns the line number of the caller.
StringgetMethodName()
Returns the method name of the caller.

Field Detail

fullInfo

public String fullInfo
All available caller information, in the format fully.qualified.classname.of.caller.methodName(Filename.java:line)

NA

public static final String NA
When location information is not available the constant NA is returned. Current value of this string constant is ?.

Constructor Detail

LocationInfo

public LocationInfo(Throwable t, String fqnOfCallingClass)
Instantiate location information based on a Throwable. We expect the Throwable t, to be in the format
        java.lang.Throwable
        ...
          at org.apache.log4j.PatternLayout.format(PatternLayout.java:413)
          at org.apache.log4j.FileAppender.doAppend(FileAppender.java:183)
        at org.apache.log4j.Category.callAppenders(Category.java:131)
        at org.apache.log4j.Category.log(Category.java:512)
        at callers.fully.qualified.className.methodName(FileName.java:74)
	...
       

However, we can also deal with JIT compilers that "lose" the location information, especially between the parentheses.

Method Detail

getClassName

public String getClassName()
Return the fully qualified class name of the caller making the logging request.

getFileName

public String getFileName()
Return the file name of the caller.

This information is not always available.

getLineNumber

public String getLineNumber()
Returns the line number of the caller.

This information is not always available.

getMethodName

public String getMethodName()
Returns the method name of the caller.
Copyright 2000-2005 Apache Software Foundation.