LocationInfo Class | Apache log4net™ SDK Documentation

The internal representation of caller location information.
Inheritance Hierarchy

System
Object
log4net.Core
LocationInfo

Namespace: log4net.Core
Assembly: log4net (in log4net.dll) Version: 2.0.8.0-.NET 4.0
Syntax

C#
VB
C++
F#
Copy

    [SerializableAttribute]
    public class LocationInfo

    <SerializableAttribute>
    Public Class LocationInfo

    [SerializableAttribute]
    public ref class LocationInfo

    [<SerializableAttribute>]
    type LocationInfo =  class end

The LocationInfo type exposes the following members.

Constructors

| Name | Description
--- | --- | ---
| LocationInfo(Type) | Constructor
| LocationInfo(String, String, String, String) | Constructor

Top
Properties

| Name | Description
--- | --- | ---
| ClassName | Gets the fully qualified class name of the caller making the logging request.
| FileName | Gets the file name of the caller.
| FullInfo | Gets all available caller information
| LineNumber | Gets the line number of the caller.
| MethodName | Gets the method name of the caller.
| StackFrames | Gets the stack frames from the stack trace of the caller making the log request

Top
Methods

| Name | Description
--- | --- | ---
| Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
| Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
| GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
| GetType | Gets the Type of the current instance. (Inherited from Object.)
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
| ToString | Returns a String that represents the current Object. (Inherited from Object.)

Top
Remarks

This class uses the System.Diagnostics.StackTrace class to generate a call stack. The caller's information is then extracted from this stack.

The System.Diagnostics.StackTrace class is not supported on the .NET Compact Framework 1.0 therefore caller location information is not available on that framework.

The System.Diagnostics.StackTrace class has this to say about Release builds:

"StackTrace information will be most informative with Debug build configurations. By default, Debug builds include debug symbols, while Release builds do not. The debug symbols contain most of the file, method name, line number, and column information used in constructing StackFrame and StackTrace objects. StackTrace might not report as many method calls as expected, due to code transformations that occur during optimization."

This means that in a Release build the caller information may be incomplete or may not exist at all! Therefore caller location information cannot be relied upon in a Release build.

See Also

#### Reference

log4net.Core Namespace