Table of Contents

Interface ILoggerWrapper<T>

Namespace
Arc4u.Diagnostics
Assembly
Arc4u.Diagnostics.dll

An ILogger<TCategoryName> that lets callers attach extra properties (see LoggerWrapperExtensions) and a message category to the log entry before it is written.

public interface ILoggerWrapper<T> : ILogger<T>, ILogger, ILoggerCallerMember

Type Parameters

T

The category type of the logger.

Inherited Members
Extension Methods

Properties

AdditionalFields

Gets the additional properties that are written with the next log entry of this logger.

Dictionary<string, object?> AdditionalFields { get; }

Property Value

Dictionary<string, object>

Remarks

The properties are cleared once the entry is written.

IncludeStackTrace

Sets a value indicating whether the stack trace is added to the next log entry; reset once the entry is written.

bool IncludeStackTrace { set; }

Property Value

bool

Methods

SetContext(string, string, Type?)

Returns a logger that writes its entries with the category, the calling member and optionally the source context type given.

ILoggerWrapper<T> SetContext(string category, string caller = "", Type? realType = null)

Parameters

category string

The message category, see MessageCategory.

caller string

The name of the calling member.

realType Type

The type to report as the source context instead of T, or null to keep T.

Returns

ILoggerWrapper<T>

The logger wrapper to use for the entry.

Remarks

The returned logger has its own additional fields, so a logger shared between callers (or threads) is never modified by an entry being prepared.