LoggerExtensions Class

ILogger extension methods for common scenarios.

Namespace
Microsoft.Extensions.Logging
Assemblies
  • Microsoft.Extensions.Logging.Abstractions

Syntax

public class LoggerExtensions
class Microsoft.Extensions.Logging.LoggerExtensions

Methods

BeginScope(Microsoft.Extensions.Logging.ILogger, System.String, System.Object[])

Formats the message and creates a scope.

Arguments:
Return type:

System.IDisposable

Returns:

A disposable scope object. Can be null.

public static IDisposable BeginScope(this ILogger logger, string messageFormat, params object[] args)
LogCritical(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[])

Formats and writes a critical log message.

Arguments:
public static void LogCritical(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
LogCritical(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.String, System.Object[])

Formats and writes a critical log message.

Arguments:
public static void LogCritical(this ILogger logger, EventId eventId, string message, params object[] args)
LogCritical(Microsoft.Extensions.Logging.ILogger, System.String, System.Object[])

Formats and writes a critical log message.

Arguments:
public static void LogCritical(this ILogger logger, string message, params object[] args)
LogDebug(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[])

Formats and writes a debug log message.

Arguments:
public static void LogDebug(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
LogDebug(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.String, System.Object[])

Formats and writes a debug log message.

Arguments:
public static void LogDebug(this ILogger logger, EventId eventId, string message, params object[] args)
LogDebug(Microsoft.Extensions.Logging.ILogger, System.String, System.Object[])

Formats and writes a debug log message.

Arguments:
public static void LogDebug(this ILogger logger, string message, params object[] args)
LogError(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[])

Formats and writes an error log message.

Arguments:
public static void LogError(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
LogError(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.String, System.Object[])

Formats and writes an error log message.

Arguments:
public static void LogError(this ILogger logger, EventId eventId, string message, params object[] args)
LogError(Microsoft.Extensions.Logging.ILogger, System.String, System.Object[])

Formats and writes an error log message.

Arguments:
public static void LogError(this ILogger logger, string message, params object[] args)
LogInformation(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[])

Formats and writes an informational log message.

Arguments:
public static void LogInformation(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
LogInformation(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.String, System.Object[])

Formats and writes an informational log message.

Arguments:
public static void LogInformation(this ILogger logger, EventId eventId, string message, params object[] args)
LogInformation(Microsoft.Extensions.Logging.ILogger, System.String, System.Object[])

Formats and writes an informational log message.

Arguments:
public static void LogInformation(this ILogger logger, string message, params object[] args)
LogTrace(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[])

Formats and writes a trace log message.

Arguments:
public static void LogTrace(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
LogTrace(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.String, System.Object[])

Formats and writes a trace log message.

Arguments:
public static void LogTrace(this ILogger logger, EventId eventId, string message, params object[] args)
LogTrace(Microsoft.Extensions.Logging.ILogger, System.String, System.Object[])

Formats and writes a trace log message.

Arguments:
public static void LogTrace(this ILogger logger, string message, params object[] args)
LogWarning(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[])

Formats and writes a warning log message.

Arguments:
public static void LogWarning(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
LogWarning(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.String, System.Object[])

Formats and writes a warning log message.

Arguments:
public static void LogWarning(this ILogger logger, EventId eventId, string message, params object[] args)
LogWarning(Microsoft.Extensions.Logging.ILogger, System.String, System.Object[])

Formats and writes a warning log message.

Arguments:
public static void LogWarning(this ILogger logger, string message, params object[] args)