EventDefinition<TParam1,TParam2> Class

Definition

Defines metadata for an event with three parameters and a cached delegate to log the event with reduced allocations.

public class EventDefinition<TParam1,TParam2> : Microsoft.EntityFrameworkCore.Diagnostics.EventDefinitionBase
type EventDefinition<'TParam1, 'TParam2> = class
    inherit EventDefinitionBase
Public Class EventDefinition(Of TParam1, TParam2)
Inherits EventDefinitionBase

Type Parameters

TParam1
TParam2
Inheritance
EventDefinition<TParam1,TParam2>

Remarks

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

Constructors

EventDefinition<TParam1,TParam2>(EventId, LogLevel, Action<ILogger,TParam1,TParam2,Exception>)

Creates an event definition instance.

EventDefinition<TParam1,TParam2>(EventId, LogLevel, String, Action<ILogger,TParam1,TParam2,Exception>)

Creates an event definition instance.

EventDefinition<TParam1,TParam2>(ILoggingOptions, EventId, LogLevel, String, Func<LogLevel,Action<ILogger,TParam1,TParam2,Exception>>)

Creates an event definition instance.

Properties

EventId

The EventId.

(Inherited from EventDefinitionBase)
EventIdCode

A string representing the code that should be passed to ConfigureWarnings(Action<WarningsConfigurationBuilder>) to suppress this event as an error.

(Inherited from EventDefinitionBase)
Level

The LogLevel at which the event will be logged.

(Inherited from EventDefinitionBase)
WarningBehavior

The configured WarningBehavior.

(Inherited from EventDefinitionBase)

Methods

GenerateMessage(TParam1, TParam2)

Generates the message that would be logged without logging it. Typically used for throwing an exception in warning-as-error cases.

GenerateMessage(TParam1, TParam2, Exception)

Generates the message that would be logged without logging it. Typically used for throwing an exception in warning-as-error cases.

GetLogBehavior<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory>)

Gets the log behavior for this event. This determines whether it should be logged, thrown as an exception or ignored.

(Inherited from EventDefinitionBase)
Log<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory>, TParam1, TParam2)

Logs the event, or throws if the event has been configured to be treated as an error.

Log<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory>, TParam1, TParam2, Exception)
Obsolete.

Logs the event, or throws if the event has been configured to be treated as an error.

Log<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory>, WarningBehavior, TParam1, TParam2)

Logs the event, or throws if the event has been configured to be treated as an error.

Log<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory>, WarningBehavior, TParam1, TParam2, Exception)

Logs the event, or throws if the event has been configured to be treated as an error.

WarningAsError(String)

Returns a warning-as-error exception wrapping the given message for this event.

(Inherited from EventDefinitionBase)

Applies to