Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Microsoft.​Extensions.​Logging.​LoggerExtensions

Assembly: Microsoft.Extensions.Logging.Abstractions

Inheritance: object → LoggerExtensions

ILogger extension methods for common scenarios.

Methods

public static System.​IDisposable
BeginScope​(ILogger logger, string messageFormat, object[] args)
Formats the message and creates a scope.
Returns A disposable scope object. Can be null.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to create the scope in.
messageFormat Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
Log​(ILogger logger, LogLevel logLevel, EventId eventId, System.​Exception exception, string message, object[] args)
Formats and writes a log message at the specified log level.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
logLevel Entry will be written on this level.
eventId The event id associated with the log.
exception The exception to log.
message Format string of the log message.
args An object array that contains zero or more objects to format.
public static void
Log​(ILogger logger, LogLevel logLevel, EventId eventId, string message, object[] args)
Formats and writes a log message at the specified log level.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
logLevel Entry will be written on this level.
eventId The event id associated with the log.
message Format string of the log message.
args An object array that contains zero or more objects to format.
public static void
Log​(ILogger logger, LogLevel logLevel, System.​Exception exception, string message, object[] args)
Formats and writes a log message at the specified log level.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
logLevel Entry will be written on this level.
exception The exception to log.
message Format string of the log message.
args An object array that contains zero or more objects to format.
public static void
Log​(ILogger logger, LogLevel logLevel, string message, object[] args)
Formats and writes a log message at the specified log level.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
logLevel Entry will be written on this level.
message Format string of the log message.
args An object array that contains zero or more objects to format.
public static void
LogCritical​(ILogger logger, EventId eventId, System.​Exception exception, string message, object[] args)
Formats and writes a critical log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogCritical​(ILogger logger, EventId eventId, string message, object[] args)
Formats and writes a critical log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogCritical​(ILogger logger, System.​Exception exception, string message, object[] args)
Formats and writes a critical log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogCritical​(ILogger logger, string message, object[] args)
Formats and writes a critical log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogDebug​(ILogger logger, EventId eventId, System.​Exception exception, string message, object[] args)
Formats and writes a debug log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogDebug​(ILogger logger, EventId eventId, string message, object[] args)
Formats and writes a debug log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogDebug​(ILogger logger, System.​Exception exception, string message, object[] args)
Formats and writes a debug log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogDebug​(ILogger logger, string message, object[] args)
Formats and writes a debug log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogError​(ILogger logger, EventId eventId, System.​Exception exception, string message, object[] args)
Formats and writes an error log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogError​(ILogger logger, EventId eventId, string message, object[] args)
Formats and writes an error log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogError​(ILogger logger, System.​Exception exception, string message, object[] args)
Formats and writes an error log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogError​(ILogger logger, string message, object[] args)
Formats and writes an error log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogInformation​(ILogger logger, EventId eventId, System.​Exception exception, string message, object[] args)
Formats and writes an informational log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogInformation​(ILogger logger, EventId eventId, string message, object[] args)
Formats and writes an informational log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogInformation​(ILogger logger, System.​Exception exception, string message, object[] args)
Formats and writes an informational log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogInformation​(ILogger logger, string message, object[] args)
Formats and writes an informational log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogTrace​(ILogger logger, EventId eventId, System.​Exception exception, string message, object[] args)
Formats and writes a trace log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogTrace​(ILogger logger, EventId eventId, string message, object[] args)
Formats and writes a trace log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogTrace​(ILogger logger, System.​Exception exception, string message, object[] args)
Formats and writes a trace log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogTrace​(ILogger logger, string message, object[] args)
Formats and writes a trace log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogWarning​(ILogger logger, EventId eventId, System.​Exception exception, string message, object[] args)
Formats and writes a warning log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogWarning​(ILogger logger, EventId eventId, string message, object[] args)
Formats and writes a warning log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
eventId The event id associated with the log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogWarning​(ILogger logger, System.​Exception exception, string message, object[] args)
Formats and writes a warning log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
exception The exception to log.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public static void
LogWarning​(ILogger logger, string message, object[] args)
Formats and writes a warning log message.
logger The <see cref="T:Microsoft.Extensions.Logging.ILogger" /> to write to.
message Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c> .
args An object array that contains zero or more objects to format.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object