Open sandboxFocus

Class ThreadLoggingContext

A LoggingContext that represents the current thread. The ThreadLoggingContext has two uses. First, it is used to store all thread-local variables and objects. Second, it is used as the root object for all other contexts.

Inheritance
ThreadLoggingContext
Namespace: PostSharp.Patterns.Diagnostics.Contexts
Assembly: PostSharp.Patterns.Diagnostics.dll
Syntax
public class ThreadLoggingContext : LoggingContext, ILoggingContext, IDisposable
Remarks

A custom backend that needs to store more data in this context can derive a class from it and override CreateThreadContext() to return an instance of the derived class.

Constructors

Name Description
ThreadLoggingContext(LoggingBackend, LogRecordBuilder)

Initializes a new instance of the ThreadLoggingContext class.

Properties

Name Description
IsAsync

Gets a value indicating whether the current LoggingContext represents an async method or an asynchronous custom activity.

IsLogging

Gets a value indicating whether the current thread is emitting a log record. This allows avoiding infinite recursion while logging.

SyntheticId

Gets a cross-process globally unique identifier for the current LoggingContext. This value is created according to the value of the LoggingBackend.Options.SyntheticIdFormatter property.

ThreadContext

Gets the ThreadLoggingContext for the thread in which the current LoggingContext is currently executed.

Methods

Name Description
Dispose(bool)

Disposes the current object.

GetCustomRecordBuilder(LoggingContext, ref CustomLogRecordInfo)

Gets a LogRecordBuilder and initializes it to emit a custom record.

GetRecordBuilder(LoggingContext, ref LogRecordInfo, ref LogMemberInfo)

Gets a LogRecordBuilder and initializes it for a given context, member, and record.

ToString(StringBuilder)

Formats a description of the current LoggingContext into a given StringBuilder.

See Also