Auf Englisch lesen

Freigeben über


ILogger.Log<TState> Method

Definition

Writes a log entry.

C#
public void Log<TState>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state, Exception? exception, Func<TState,Exception?,string> formatter);

Type Parameters

TState

The type of the object to be written.

Parameters

logLevel
LogLevel

Entry will be written on this level.

eventId
EventId

Id of the event.

state
TState

The entry to be written. Can be also an object.

exception
Exception

The exception related to this entry.

formatter
Func<TState,Exception,String>

Function to create a String message of the state and exception.

Remarks

The default formatter provided by the logger extension methods doesn't include the exception when formatting messages. It's essential for implementations of this method to decide how exceptions should be incorporated into the logs.

Applies to

Produkt Versionen
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)