Open sandboxFocus

Class LoggingBackend

Base class for all logging back-ends (sometimes names sinks, targets, listeners) of the PostSharp logging system.

Implements
Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics.dll
Syntax
public abstract class LoggingBackend : IDisposable
Remarks

If you want to implement your own logging back-end, deriving from the TextLoggingBackend class, which implements standard logic for logging a text.

Constructors

Name Description
LoggingBackend()

Initializes a new LoggingBackend.

Properties

Name Description
CurrentContext

Gets the current LoggingContext.

CurrentContextLocalConfiguration

Gets the LoggingContextLocalConfiguration for the current execution. Returns DefaultContextLocalConfiguration unless the context has been overwritten by WithContextLocalConfiguration(LoggingContextLocalConfiguration).

DefaultContextLocalConfiguration

Gets the default LoggingContextLocalConfiguration, used unless it has been overwritten by the WithContextLocalConfiguration(LoggingContextLocalConfiguration) for the current execution context.

DefaultVerbosity

Gets the LoggingVerbosityConfiguration of the DefaultContextLocalConfiguration.

IsCorrupted

Determines whether the current LoggingBackend is in a state where it can no longer be recovered. This typically happens when an exception occurs while disabling or enabling.

IsDisposed

Determines whether the current LoggingBackend has been disposed.

IsEnabled

Determines whether the current LoggingBackend is currently enabled. This property has precedence over, and does not affect, the minimal log levels set through the SetLevel(LogLevel) method.

Options

Gets the formatting and rendering options for the current LoggingBackend.

TransactionPolicySelector

Gets or sets the selector that determines what policy to apply for each transaction or whether the transaction should be logged as a transaction at all.

Methods

Name Description
CreateAsyncCustomActivityContext()

Creates a new AsyncCustomActivityLoggingContext.

CreateAsyncMethodContext()

Creates a new AsyncMethodLoggingContext for a given async method.

CreateContextLocalConfiguration(LoggingVerbosityConfiguration)

Creates a new LoggingContextLocalConfiguration.

CreateEphemeralContext(ThreadLoggingContext)

Creates a new EphemeralLoggingContext.

CreateExecutionContextData()

Creates a new empty instance of PostSharp.Patterns.Diagnostics.LoggingBackend.ExecutionContextData possibly of a subclass which can hold backend-specific data.

CreateIteratorContext()

Creates a new IteratorLoggingContext for a given iterator method.

CreateRecordBuilder()

Creates a new LogRecordBuilder.

CreateSyncCustomActivityContext(ThreadLoggingContext)

Creates a new SyncCustomActivityLoggingContext.

CreateSyncMethodContext(ThreadLoggingContext)

Creates a new SyncMethodLoggingContext for a given normal (non-async, non-iterator) method.

CreateThreadContext()

Creates a new ThreadLoggingContext.

CreateTransaction(LoggingTypeSource, in TransactionProperties, ITransactionPolicy)

Creates a LoggingTransaction instance.

CreateTypeSource(LoggingNamespaceSource, Type)

Creates a LoggingTypeSource for the given role and type.

CreateTypeSourceBySourceName(LoggingNamespaceSource, string)

Creates a LoggingTypeSource for the given role and logger name.

CreateVerbosityConfiguration()

Creates a new LoggingVerbosityConfiguration for the current LoggingBackend.

Dispose()
Dispose(bool)

Disposes the current object.

GetAsyncContextOfTask(Task)

Gets the AsyncMethodLoggingContext associated with a Task.

GetBackendOptions()

Gets the formatting and rendering options for the current LoggingBackend.

GetSource(string, string)

Returns a LoggingNamespaceSource for the given role and, optionally, namespace.

GetSource(string, Type)

Returns a LoggingTypeSource for the given role and type.

GetThreadContext()

Returns the ThreadLoggingContext for the current Thread.

OpenAsyncContext(AsyncCallId, ref LogMemberInfo)

Gets an AsyncMethodLoggingContext for a given async method.

OpenEphemeralContext(ref LogMemberInfo)

Gets an EphemeralLoggingContext for use in a given method. An EphemeralLoggingContext is a degenerated kind of context, used to emit a single record.

OpenEphemeralContext(LoggingTypeSource, ref ThreadLoggingContext)

Gets an EphemeralLoggingContext for use in a given LoggingTypeSource. An EphemeralLoggingContext is a degenerated kind of context, used to emit a single record.

OpenIteratorContext(IEnumerator, ref LogMemberInfo)

Gets an IteratorLoggingContext for a given iterator method.

OpenSyncContext(ref LogMemberInfo)

Gets a SyncMethodLoggingContext for a given normal (non-async, non-iterator) method.

ToString()
WithContextLocalConfiguration(LoggingContextLocalConfiguration)

Changes the LoggingContextLocalConfiguration for the current execution context.

WithVerbosityConfiguration(LoggingVerbosityConfiguration)

Changes the verbosity for the current execution context.