Log4j 1.3alpha-8

org.apache.log4j.spi
Class LocationInfo

java.lang.Object
  |
  +--org.apache.log4j.spi.LocationInfo
All Implemented Interfaces:
Serializable

public class LocationInfo
extends Object
implements Serializable

The internal representation of caller location information.

Since:
0.8.3
See Also:
Serialized Form

Field Summary
 String className
          Caller's fully qualified class name.
 String fileName
          Caller's file name.
 String fullInfo
          All available caller information, in the format fully.qualified.classname.of.caller.methodName(Filename.java:line)
 String lineNumber
          Caller's line number.
 String methodName
          Caller's method name.
static String NA
          When location information is not available the constant NA is returned.
static LocationInfo NA_LOCATION_INFO
          NA_LOCATION_INFO is used in conjunction with deserialized LoggingEvents without real location info available.
 
Constructor Summary
LocationInfo(String fileName, String className, String methodName, String lineNumber)
           
LocationInfo(Throwable t, String fqnOfInvokingClass)
          Instantiate location information based on a Throwable.
 
Method Summary
 boolean equals(Object o)
           
 String getClassName()
          Return the fully qualified class name of the caller making the logging request.
 String getFileName()
          Return the file name of the caller.
 String getFullInfo()
          fullInfo format is: fully.qualified.classname.of.caller.methodName(Filename.java:line)
 String getLineNumber()
          Returns the line number of the caller.
 String getMethodName()
          Returns the method name of the caller.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NA

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

NA_LOCATION_INFO

public static LocationInfo NA_LOCATION_INFO
NA_LOCATION_INFO is used in conjunction with deserialized LoggingEvents without real location info available.
Since:
1.3

lineNumber

public String lineNumber
Caller's line number.

fileName

public String fileName
Caller's file name.

className

public String className
Caller's fully qualified class name.

methodName

public String methodName
Caller's method name.

fullInfo

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

LocationInfo

public LocationInfo(String fileName,
                    String className,
                    String methodName,
                    String lineNumber)

LocationInfo

public LocationInfo(Throwable t,
                    String fqnOfInvokingClass)
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

equals

public boolean equals(Object o)
Overrides:
equals in class Object

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.

getFullInfo

public String getFullInfo()
fullInfo format is: fully.qualified.classname.of.caller.methodName(Filename.java:line)

toString

public String toString()
Overrides:
toString in class Object

Log4j 1.3alpha-8

Copyright © 2000-2006 Apache Software Foundation.
Licensed under the Apache License, Version 2.0.