Table of Contents

Class ContextItems

Namespace
Microsoft.Practices.EnterpriseLibrary.Logging
Assembly
Microsoft.Practices.EnterpriseLibrary.Logging.dll

Provides methods to maintain a key/value dictionary that is stored in the System.Runtime.Remoting.Messaging.CallContext.

public class ContextItems
Inheritance
ContextItems
Inherited Members

Remarks

A context item represents a key/value that needs to be logged with each message on the same CallContext.

Constructors

ContextItems()

Creates a new instance of a ContextItems class.

public ContextItems()

Fields

CallContextSlotName

The name of the data slot in the System.Runtime.Remoting.Messaging.CallContext used by the application block.

public const string CallContextSlotName = "EntLibLoggerContextItems"

Field Value

string

Methods

FlushContextItems()

Empties the context items dictionary.

[SecurityCritical]
public void FlushContextItems()

ProcessContextItems(LogEntry)

Merges each key/value pair from the context items dictionary with the ExtendedProperties dictionary of the LogEntry.

public void ProcessContextItems(LogEntry log)

Parameters

log LogEntry

LogEntry object that is being logged.

SetContextItem(object, object)

Adds a key/value pair to a dictionary in the System.Runtime.Remoting.Messaging.CallContext.
Each context item is recorded with every log entry.

[SecurityCritical]
public void SetContextItem(object key, object value)

Parameters

key object

Hashtable key.

value object

Value of the context item. Byte arrays will be base64 encoded.

Examples

The following example demonstrates use of the AddContextItem method.

Logger.SetContextItem("SessionID", myComponent.SessionId);