Interface ILogger
- Namespace
- Microsoft.Extensions.Logging
- Assembly
- Microsoft.Extensions.Logging.Abstractions.dll
Represents a type used to perform logging.
public interface ILogger
- Extension Methods
Remarks
Aggregates most logging patterns to a single method.
Methods
BeginScope<TState>(TState)
Begins a logical operation scope.
IDisposable BeginScope<TState>(TState state)
Parameters
state
TStateThe identifier for the scope.
Returns
- IDisposable
An IDisposable that ends the logical operation scope on dispose.
Type Parameters
TState
IsEnabled(LogLevel)
Checks if the given logLevel
is enabled.
bool IsEnabled(LogLevel logLevel)
Parameters
logLevel
LogLevellevel to be checked.
Returns
- bool
true
if enabled.
Log<TState>(LogLevel, EventId, TState, Exception, Func<TState, Exception, string>)
Writes a log entry.
void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
Parameters
logLevel
LogLevelEntry will be written on this level.
eventId
EventIdId of the event.
state
TStateThe entry to be written. Can be also an object.
exception
ExceptionThe exception related to this entry.
formatter
Func<TState, Exception, string>Function to create a
string
message of thestate
andexception
.
Type Parameters
TState