Class LoggerExtensions
Provides standard methods for logging messages at different levels.
Inheritance
Inherited Members
Namespace: EPiServer.Logging
Assembly: EPiServer.Framework.dll
Version: 11.20.7Syntax
public static class LoggerExtensions
Methods
Critical(ILogger, String)
Logs the specified message at the Critical level.
Declaration
public static void Critical(this ILogger logger, string message)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Critical(ILogger, String, Exception)
Logs the specified message and exception at the Critical level.
Declaration
public static void Critical(this ILogger logger, string message, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
System.Exception | exception | The exception that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Critical(ILogger, String, Object[])
Logs the specified message at the Critical level using the supplied format and arguments.
Declaration
public static void Critical(this ILogger logger, string messageFormat, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | messageFormat | The message format string. |
System.Object[] | args | The arguments that should be used to format the message. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Critical<TState>(ILogger, TState, Func<TState, String>)
Logs a message at the Critical level using the supplied formatter and state.
Declaration
public static void Critical<TState>(this ILogger logger, TState state, Func<TState, string> messageFormatter)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
System.Func<TState, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Critical<TState, TException>(ILogger, TState, TException, Func<TState, TException, String>)
Logs a message and exception at the Critical level using the supplied formatter and state.
Declaration
public static void Critical<TState, TException>(this ILogger logger, TState state, TException exception, Func<TState, TException, string> messageFormatter)
where TException : Exception
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
TException | exception | The exception that should be logged. |
System.Func<TState, TException, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
TException | The type of the exception that is being logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Debug(ILogger, String)
Logs the specified message at the Debug level.
Declaration
public static void Debug(this ILogger logger, string message)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Debug(ILogger, String, Exception)
Logs the specified message and exception at the Debug level.
Declaration
public static void Debug(this ILogger logger, string message, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
System.Exception | exception | The exception that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Debug(ILogger, String, Object[])
Logs the specified message at the Debug level using the supplied format and arguments.
Declaration
public static void Debug(this ILogger logger, string messageFormat, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | messageFormat | The message format string. |
System.Object[] | args | The arguments that should be used to format the message. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Debug<TState>(ILogger, TState, Func<TState, String>)
Logs a message at the Debug level using the supplied formatter and state.
Declaration
public static void Debug<TState>(this ILogger logger, TState state, Func<TState, string> messageFormatter)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
System.Func<TState, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Debug<TState, TException>(ILogger, TState, TException, Func<TState, TException, String>)
Logs a message and exception at the Debug level using the supplied formatter and state.
Declaration
public static void Debug<TState, TException>(this ILogger logger, TState state, TException exception, Func<TState, TException, string> messageFormatter)
where TException : Exception
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
TException | exception | The exception that should be logged. |
System.Func<TState, TException, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
TException | The type of the exception that is being logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Error(ILogger, String)
Logs the specified message at the Error level.
Declaration
public static void Error(this ILogger logger, string message)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Error(ILogger, String, Exception)
Logs the specified message and exception at the Error level.
Declaration
public static void Error(this ILogger logger, string message, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
System.Exception | exception | The exception that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Error(ILogger, String, Object[])
Logs the specified message at the Error level using the supplied format and arguments.
Declaration
public static void Error(this ILogger logger, string messageFormat, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | messageFormat | The message format string. |
System.Object[] | args | The arguments that should be used to format the message. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Error<TState>(ILogger, TState, Func<TState, String>)
Logs a message at the Error level using the supplied formatter and state.
Declaration
public static void Error<TState>(this ILogger logger, TState state, Func<TState, string> messageFormatter)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
System.Func<TState, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Error<TState, TException>(ILogger, TState, TException, Func<TState, TException, String>)
Logs a message and exception at the Error level using the supplied formatter and state.
Declaration
public static void Error<TState, TException>(this ILogger logger, TState state, TException exception, Func<TState, TException, string> messageFormatter)
where TException : Exception
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
TException | exception | The exception that should be logged. |
System.Func<TState, TException, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
TException | The type of the exception that is being logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Information(ILogger, String)
Logs the specified message at the Information level.
Declaration
public static void Information(this ILogger logger, string message)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Information(ILogger, String, Exception)
Logs the specified message and exception at the Information level.
Declaration
public static void Information(this ILogger logger, string message, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
System.Exception | exception | The exception that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Information(ILogger, String, Object[])
Logs the specified message at the Information level using the supplied format and arguments.
Declaration
public static void Information(this ILogger logger, string messageFormat, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | messageFormat | The message format string. |
System.Object[] | args | The arguments that should be used to format the message. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Information<TState>(ILogger, TState, Func<TState, String>)
Logs a message at the Information level using the supplied formatter and state.
Declaration
public static void Information<TState>(this ILogger logger, TState state, Func<TState, string> messageFormatter)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
System.Func<TState, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Information<TState, TException>(ILogger, TState, TException, Func<TState, TException, String>)
Logs a message and exception at the Information level using the supplied formatter and state.
Declaration
public static void Information<TState, TException>(this ILogger logger, TState state, TException exception, Func<TState, TException, string> messageFormatter)
where TException : Exception
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
TException | exception | The exception that should be logged. |
System.Func<TState, TException, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
TException | The type of the exception that is being logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
IsCriticalEnabled(ILogger)
Checks if Critical logging is enabled.
Declaration
public static bool IsCriticalEnabled(this ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsDebugEnabled(ILogger)
Checks if Debug logging is enabled.
Declaration
public static bool IsDebugEnabled(this ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsErrorEnabled(ILogger)
Checks if Error logging is enabled.
Declaration
public static bool IsErrorEnabled(this ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsInformationEnabled(ILogger)
Checks if Information logging is enabled.
Declaration
public static bool IsInformationEnabled(this ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsTraceEnabled(ILogger)
Checks if Trace logging is enabled.
Declaration
public static bool IsTraceEnabled(this ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsWarningEnabled(ILogger)
Checks if Warning logging is enabled.
Declaration
public static bool IsWarningEnabled(this ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger |
Returns
Type | Description |
---|---|
System.Boolean |
|
Log(ILogger, Level, String)
Logs the specified message at the provided level.
Declaration
public static void Log(this ILogger logger, Level level, string message)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
Level | level | The level at which to log the message. |
System.String | message | The message that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Log(ILogger, Level, String, Exception)
Logs the specified message and exception at the provided level.
Declaration
public static void Log(this ILogger logger, Level level, string message, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
Level | level | The level at which to log the message. |
System.String | message | The message that should be logged. |
System.Exception | exception | The exception that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Log(ILogger, Level, String, Object[])
Logs a message at the provided level using the supplied format and arguments.
Declaration
public static void Log(this ILogger logger, Level level, string messageFormat, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
Level | level | The level at which to log the message. |
System.String | messageFormat | The message format string. |
System.Object[] | args | The arguments. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Log<TState>(ILogger, Level, TState, Func<TState, String>)
Logs a message at the provided level using the supplied formatter and state.
Declaration
public static void Log<TState>(this ILogger logger, Level level, TState state, Func<TState, string> messageFormatter)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
Level | level | The level at which to log the message. |
TState | state | A state object to pass to the message formatter. |
System.Func<TState, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Log<TState, TException>(ILogger, Level, TState, TException, Func<TState, TException, String>)
Logs a message and exception at the provided level using the supplied formatter and state.
Declaration
public static void Log<TState, TException>(ILogger logger, Level level, TState state, TException exception, Func<TState, TException, string> messageFormatter)
where TException : Exception
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
Level | level | The level at which to log the message. |
TState | state | A state object to pass to the message formatter. |
TException | exception | The exception that should be logged. |
System.Func<TState, TException, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
TException | The type of the exception that is being logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Trace(ILogger, String)
Logs the specified message at the Trace level.
Declaration
public static void Trace(this ILogger logger, string message)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Trace(ILogger, String, Exception)
Logs the specified message and exception at the Trace level.
Declaration
public static void Trace(this ILogger logger, string message, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
System.Exception | exception | The exception that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Trace(ILogger, String, Object[])
Logs the specified message at the Trace level using the supplied format and arguments.
Declaration
public static void Trace(this ILogger logger, string messageFormat, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | messageFormat | The message format string. |
System.Object[] | args | The arguments that should be used to format the message. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Trace<TState>(ILogger, TState, Func<TState, String>)
Logs a message at the Trace level using the supplied formatter and state.
Declaration
public static void Trace<TState>(this ILogger logger, TState state, Func<TState, string> messageFormatter)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
System.Func<TState, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Trace<TState, TException>(ILogger, TState, TException, Func<TState, TException, String>)
Logs a message and exception at the Trace level using the supplied formatter and state.
Declaration
public static void Trace<TState, TException>(this ILogger logger, TState state, TException exception, Func<TState, TException, string> messageFormatter)
where TException : Exception
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
TException | exception | The exception that should be logged. |
System.Func<TState, TException, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
TException | The type of the exception that is being logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Warning(ILogger, String)
Logs the specified message at the Warning level.
Declaration
public static void Warning(this ILogger logger, string message)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Warning(ILogger, String, Exception)
Logs the specified message and exception at the Warning level.
Declaration
public static void Warning(this ILogger logger, string message, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | message | The message that should be logged. |
System.Exception | exception | The exception that should be logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Warning(ILogger, String, Object[])
Logs the specified message at the Warning level using the supplied format and arguments.
Declaration
public static void Warning(this ILogger logger, string messageFormat, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
System.String | messageFormat | The message format string. |
System.Object[] | args | The arguments that should be used to format the message. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Warning<TState>(ILogger, TState, Func<TState, String>)
Logs a message at the Warning level using the supplied formatter and state.
Declaration
public static void Warning<TState>(this ILogger logger, TState state, Func<TState, string> messageFormatter)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
System.Func<TState, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |
Warning<TState, TException>(ILogger, TState, TException, Func<TState, TException, String>)
Logs a message and exception at the Warning level using the supplied formatter and state.
Declaration
public static void Warning<TState, TException>(this ILogger logger, TState state, TException exception, Func<TState, TException, string> messageFormatter)
where TException : Exception
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The logger. |
TState | state | A state object to pass to the message formatter. |
TException | exception | The exception that should be logged. |
System.Func<TState, TException, System.String> | messageFormatter | A message formatter that will be called when formatting the log message. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object that should be passed to the formatter method. |
TException | The type of the exception that is being logged. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | logger |