Search Results for

    Show / Hide Table of Contents

    Class LoggerExtensions

    ILogger extension methods for common scenarios.

    Inheritance
    object
    LoggerExtensions
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Microsoft.Extensions.Logging
    Assembly: nanoFramework.Logging.dll
    Syntax
    public static class LoggerExtensions

    Properties

    MessageFormatter

    Provide a way to have the message formated

    Declaration
    public static MethodInfo MessageFormatter { get; set; }
    Property Value
    Type Description
    MethodInfo

    Methods

    BeginScope(ILogger, string, params object[])

    Formats the message and creates a scope.

    Declaration
    public static IDisposable BeginScope(this ILogger logger, string messageFormat, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to create the scope in.

    string messageFormat

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Returns
    Type Description
    IDisposable

    A disposable scope object. Can be null.

    Examples

    using(logger.BeginScope("Processing request from {Address}", address)) { }

    Log(ILogger, LogLevel, EventId, Exception, string, params object[])

    Formats and writes a log message at the specified log level.

    Declaration
    public static void Log(this ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    LogLevel logLevel

    Entry will be written on this level.

    EventId eventId

    The event id associated with the log.

    Exception exception

    The exception to log.

    string message

    Format string of the log message.

    object[] args

    An object array that contains zero or more objects to format.

    Log(ILogger, LogLevel, EventId, string, params object[])

    Formats and writes a log message at the specified log level.

    Declaration
    public static void Log(this ILogger logger, LogLevel logLevel, EventId eventId, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    LogLevel logLevel

    Entry will be written on this level.

    EventId eventId

    The event id associated with the log.

    string message

    Format string of the log message.

    object[] args

    An object array that contains zero or more objects to format.

    Log(ILogger, LogLevel, Exception, string, params object[])

    Formats and writes a log message at the specified log level.

    Declaration
    public static void Log(this ILogger logger, LogLevel logLevel, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    LogLevel logLevel

    Entry will be written on this level.

    Exception exception

    The exception to log.

    string message

    Format string of the log message.

    object[] args

    An object array that contains zero or more objects to format.

    Log(ILogger, LogLevel, string, params object[])

    Formats and writes a log message at the specified log level.

    Declaration
    public static void Log(this ILogger logger, LogLevel logLevel, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    LogLevel logLevel

    Entry will be written on this level.

    string message

    Format string of the log message.

    object[] args

    An object array that contains zero or more objects to format.

    LogCritical(ILogger, EventId, Exception, string, params object[])

    Formats and writes a critical log message.

    Declaration
    public static void LogCritical(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogCritical(0, exception, "Error while processing request from {Address}", address)

    LogCritical(ILogger, EventId, string, params object[])

    Formats and writes a critical log message.

    Declaration
    public static void LogCritical(this ILogger logger, EventId eventId, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogCritical(0, "Processing request from {Address}", address)

    LogCritical(ILogger, Exception, string, params object[])

    Formats and writes a critical log message.

    Declaration
    public static void LogCritical(this ILogger logger, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogCritical(exception, "Error while processing request from {Address}", address)

    LogCritical(ILogger, string, params object[])

    Formats and writes a critical log message.

    Declaration
    public static void LogCritical(this ILogger logger, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogCritical("Processing request from {Address}", address)

    LogDebug(ILogger, EventId, Exception, string, params object[])

    Formats and writes a debug log message.

    Declaration
    public static void LogDebug(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogDebug(0, exception, "Error while processing request from {Address}", address)

    LogDebug(ILogger, EventId, string, params object[])

    Formats and writes a debug log message.

    Declaration
    public static void LogDebug(this ILogger logger, EventId eventId, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogDebug(0, "Processing request from {Address}", address)

    LogDebug(ILogger, Exception, string, params object[])

    Formats and writes a debug log message.

    Declaration
    public static void LogDebug(this ILogger logger, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogDebug(exception, "Error while processing request from {Address}", address)

    LogDebug(ILogger, string, params object[])

    Formats and writes a debug log message.

    Declaration
    public static void LogDebug(this ILogger logger, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogDebug("Processing request from {Address}", address)

    LogError(ILogger, EventId, Exception, string, params object[])

    Formats and writes an error log message.

    Declaration
    public static void LogError(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogError(0, exception, "Error while processing request from {Address}", address)

    LogError(ILogger, EventId, string, params object[])

    Formats and writes an error log message.

    Declaration
    public static void LogError(this ILogger logger, EventId eventId, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogError(0, "Processing request from {Address}", address)

    LogError(ILogger, Exception, string, params object[])

    Formats and writes an error log message.

    Declaration
    public static void LogError(this ILogger logger, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogError(exception, "Error while processing request from {Address}", address)

    LogError(ILogger, string, params object[])

    Formats and writes an error log message.

    Declaration
    public static void LogError(this ILogger logger, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogError("Processing request from {Address}", address)

    LogInformation(ILogger, EventId, Exception, string, params object[])

    Formats and writes an informational log message.

    Declaration
    public static void LogInformation(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogInformation(0, exception, "Error while processing request from {Address}", address)

    LogInformation(ILogger, EventId, string, params object[])

    Formats and writes an informational log message.

    Declaration
    public static void LogInformation(this ILogger logger, EventId eventId, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogInformation(0, "Processing request from {Address}", address)

    LogInformation(ILogger, Exception, string, params object[])

    Formats and writes an informational log message.

    Declaration
    public static void LogInformation(this ILogger logger, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogInformation(exception, "Error while processing request from {Address}", address)

    LogInformation(ILogger, string, params object[])

    Formats and writes an informational log message.

    Declaration
    public static void LogInformation(this ILogger logger, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogInformation("Processing request from {Address}", address)

    LogTrace(ILogger, EventId, Exception, string, params object[])

    Formats and writes a trace log message.

    Declaration
    public static void LogTrace(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogTrace(0, exception, "Error while processing request from {Address}", address)

    LogTrace(ILogger, EventId, string, params object[])

    Formats and writes a trace log message.

    Declaration
    public static void LogTrace(this ILogger logger, EventId eventId, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogTrace(0, "Processing request from {Address}", address)

    LogTrace(ILogger, Exception, string, params object[])

    Formats and writes a trace log message.

    Declaration
    public static void LogTrace(this ILogger logger, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogTrace(exception, "Error while processing request from {Address}", address)

    LogTrace(ILogger, string, params object[])

    Formats and writes a trace log message.

    Declaration
    public static void LogTrace(this ILogger logger, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogTrace("Processing request from {Address}", address)

    LogWarning(ILogger, EventId, Exception, string, params object[])

    Formats and writes a warning log message.

    Declaration
    public static void LogWarning(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogWarning(0, exception, "Error while processing request from {Address}", address)

    LogWarning(ILogger, EventId, string, params object[])

    Formats and writes a warning log message.

    Declaration
    public static void LogWarning(this ILogger logger, EventId eventId, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    EventId eventId

    The event id associated with the log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogWarning(0, "Processing request from {Address}", address)

    LogWarning(ILogger, Exception, string, params object[])

    Formats and writes a warning log message.

    Declaration
    public static void LogWarning(this ILogger logger, Exception exception, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    Exception exception

    The exception to log.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogWarning(exception, "Error while processing request from {Address}", address)

    LogWarning(ILogger, string, params object[])

    Formats and writes a warning log message.

    Declaration
    public static void LogWarning(this ILogger logger, string message, params object[] args)
    Parameters
    Type Name Description
    ILogger logger

    The ILogger to write to.

    string message

    Format string of the log message in message template format. Example:

    "User {User} logged in from {Address}"
    object[] args

    An object array that contains zero or more objects to format.

    Examples

    logger.LogWarning("Processing request from {Address}", address)

    In This Article
    Back to top Copyright © 2023 nanoFramework Contributors
    Generated by DocFX