Class LoggerExtensions
- Namespace
- Microsoft.Extensions.Logging
- Assembly
- nanoFramework.Logging.dll
ILogger extension methods for common scenarios.
public static class LoggerExtensions
- Inheritance
-
LoggerExtensions
- Inherited Members
Properties
MessageFormatter
Provide a way to have the message formated
public static MethodInfo MessageFormatter { get; set; }
Property Value
Methods
BeginScope(ILogger, string, params object[])
Formats the message and creates a scope.
public static IDisposable BeginScope(this ILogger logger, string messageFormat, params object[] args)
Parameters
loggerILoggerThe ILogger to create the scope in.
messageFormatstringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]An object array that contains zero or more objects to format.
Returns
- 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.
public static void Log(this ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
logLevelLogLevelEntry will be written on this level.
eventIdEventIdThe event id associated with the log.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message.
argsobject[]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.
public static void Log(this ILogger logger, LogLevel logLevel, EventId eventId, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
logLevelLogLevelEntry will be written on this level.
eventIdEventIdThe event id associated with the log.
messagestringFormat string of the log message.
argsobject[]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.
public static void Log(this ILogger logger, LogLevel logLevel, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
logLevelLogLevelEntry will be written on this level.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message.
argsobject[]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.
public static void Log(this ILogger logger, LogLevel logLevel, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
logLevelLogLevelEntry will be written on this level.
messagestringFormat string of the log message.
argsobject[]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.
public static void LogCritical(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogCritical(this ILogger logger, EventId eventId, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogCritical(this ILogger logger, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogCritical(this ILogger logger, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogDebug(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogDebug(this ILogger logger, EventId eventId, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogDebug(this ILogger logger, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogDebug(this ILogger logger, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogError(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogError(this ILogger logger, EventId eventId, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogError(this ILogger logger, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogError(this ILogger logger, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogInformation(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogInformation(this ILogger logger, EventId eventId, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogInformation(this ILogger logger, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogInformation(this ILogger logger, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogTrace(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogTrace(this ILogger logger, EventId eventId, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogTrace(this ILogger logger, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogTrace(this ILogger logger, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogWarning(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogWarning(this ILogger logger, EventId eventId, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
eventIdEventIdThe event id associated with the log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogWarning(this ILogger logger, Exception exception, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
exceptionExceptionThe exception to log.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]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.
public static void LogWarning(this ILogger logger, string message, params object[] args)
Parameters
loggerILoggerThe ILogger to write to.
messagestringFormat string of the log message in message template format. Example:
"User {User} logged in from {Address}"argsobject[]An object array that contains zero or more objects to format.
Examples
logger.LogWarning("Processing request from {Address}", address)