IDiagnosticsLogger<TLoggerCategory> Interface

Definition

Combines ILogger and DiagnosticSource for use by all EF Core logging so that events can be sent to both ILogger for ASP.NET and DiagnosticSource for everything else.

public interface IDiagnosticsLogger<TLoggerCategory> where TLoggerCategory : LoggerCategory<TLoggerCategory>, new()
public interface IDiagnosticsLogger<TLoggerCategory> : Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger where TLoggerCategory : LoggerCategory<TLoggerCategory>, new()
type IDiagnosticsLogger<'LoggerCategory (requires 'LoggerCategory :> LoggerCategory<'LoggerCategory> and 'LoggerCategory : (new : unit -> 'LoggerCategory))> = interface
type IDiagnosticsLogger<'LoggerCategory (requires 'LoggerCategory :> LoggerCategory<'LoggerCategory> and 'LoggerCategory : (new : unit -> 'LoggerCategory))> = interface
    interface IDiagnosticsLogger
Public Interface IDiagnosticsLogger(Of TLoggerCategory)
Public Interface IDiagnosticsLogger(Of TLoggerCategory)
Implements IDiagnosticsLogger

Type Parameters

TLoggerCategory
Derived
Implements

Remarks

Also intercepts messages such that warnings can be either logged or thrown, and such that a decision as to whether to log sensitive data or not can be made.

The service lifetime is Scoped. This means that each DbContext instance will use its own instance of this service. The implementation may depend on other services registered with any lifetime. The implementation does not need to be thread-safe.

See Implementation of database providers and extensions for more information and examples.

Properties

DbContextLogger

The IDbContextLogger.

(Inherited from IDiagnosticsLogger)
Definitions

Caching for logging definitions.

(Inherited from IDiagnosticsLogger)
DiagnosticSource

The DiagnosticSource.

Interceptors

Holds registered interceptors, if any.

Logger

The underlying ILogger.

Options

Entity Framework logging options.

Methods

DispatchEventData(EventDefinitionBase, EventData, Boolean, Boolean)

Dispatches the given EventData to a DiagnosticSource, if enabled, and a IDbContextLogger, if enabled.

(Inherited from IDiagnosticsLogger)
GetLogBehavior(EventId, LogLevel)

Checks if the given logLevel is enabled or the given event, and, if so, whether the event should be logged or thrown.

NeedsEventData(EventDefinitionBase, Boolean, Boolean)

Determines whether or not an EventData instance is needed based on whether or not there is a DiagnosticSource or an IDbContextLogger enabled for the given event.

(Inherited from IDiagnosticsLogger)
NeedsEventData<TInterceptor>(EventDefinitionBase, TInterceptor, Boolean, Boolean)

Determines whether or not an EventData instance is needed based on whether or not there is a DiagnosticSource, an IDbContextLogger, or an IInterceptor enabled for the given event.

(Inherited from IDiagnosticsLogger)
ShouldLog(EventDefinitionBase)

Checks whether or not the message should be sent to the ILogger.

(Inherited from IDiagnosticsLogger)
ShouldLogSensitiveData()

Gets a value indicating whether sensitive information should be written to the underlying logger. This also has the side effect of writing a warning to the log the first time sensitive data is logged.

Extension Methods

SensitiveDataLoggingEnabledWarning<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory>)

Logs for the SensitiveDataLoggingEnabledWarning event.

Applies to