Table of Contents

Class LoggerWrapper<T>

Namespace
Arc4u.Diagnostics
Assembly
Arc4u.Diagnostics.dll

Transient implementation of ILoggerWrapper<T> that decorates the ILogger<TCategoryName> created by the ILoggerFactory. The IAddPropertiesToLog it uses depends on where it is resolved: in a scope (an HTTP or gRPC request, a CreateScope()), the provider registered under the key "Scoped", which may depend on scoped services; from the root (a singleton and its dependencies), the provider registered under the key "Transient", which must not.

public sealed class LoggerWrapper<T> : LoggerBaseWrapper<T>, ILoggerWrapper<T>, ILogger<T>, ILogger, ILoggerCallerMember

Type Parameters

T

The category type of the logger.

Inheritance
LoggerWrapper<T>
Implements
Inherited Members
Extension Methods

Constructors

LoggerWrapper(ILoggerFactory, IServiceProvider, IOptionsMonitor<ApplicationConfig>)

Initializes a new instance of the LoggerWrapper<T> class.

public LoggerWrapper(ILoggerFactory loggerFactory, IServiceProvider serviceProvider, IOptionsMonitor<ApplicationConfig> appConfig)

Parameters

loggerFactory ILoggerFactory

The factory used to create the underlying logger.

serviceProvider IServiceProvider

The provider the logger is resolved from, used to choose the "Scoped" or "Transient" IAddPropertiesToLog.

appConfig IOptionsMonitor<ApplicationConfig>

The application configuration, used to obtain the application name.