GlobalContext Class | Apache log4net™ SDK Documentation

The log4net Global Context.
Inheritance Hierarchy

System
Object
log4net
GlobalContext

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

C#
VB
C++
F#
Copy

    public sealed class GlobalContext

    Public NotInheritable Class GlobalContext

    public ref class GlobalContext sealed

    [<SealedAttribute>]
    type GlobalContext =  class end

The GlobalContext type exposes the following members.

Properties

| Name | Description
--- | --- | ---
| Properties | The global properties map.

Top
Methods

| Name | Description
--- | --- | ---
| Equals | Determines whether the specified Object is equal to the current Object. (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.)
| ToString | Returns a String that represents the current Object. (Inherited from Object.)

Top
Remarks

The GlobalContext provides a location for global debugging information to be stored.

The global context has a properties map and these properties can be included in the output of log messages. The PatternLayout supports selecting and outputing these properties.

By default the log4net:HostName property is set to the name of the current machine.

Examples

C#
Copy

    GlobalContext.Properties["hostname"] = Environment.MachineName;

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.
See Also

#### Reference

log4net Namespace