Logger Class
Defines the base class used to send messages to a log.
public abstract class Logger
- Inheritance:
- object object
- Derived:
- DebuggerLogger
Constructors
Logger()
Initializes an instance of the class.
protected Logger()
Methods
BeginScope()
Begins a new scope.
public IDisposable BeginScope()
Returns
- IDisposable:
An IDisposable that should be disposed to close the scope, or
null
if scopes are not supported by the logger.
BeginScope(string?, params object?[])
Begins a new scope.
public abstract IDisposable BeginScope(string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
message | string | The format of the message be written for the scope. |
args | object[] | The optional values to be used when formatting the scope message. |
Returns
- IDisposable:
An IDisposable that should be disposed to close the scope, or
null
if scopes are not supported by the logger.
IsEnabled(LogLevel)
Gets if the given LogLevel is currently enabled. When not enabled, messages of that level will not be written.
public abstract bool IsEnabled(LogLevel logLevel)
Parameter | Type | Description |
---|---|---|
logLevel | LogLevel | The LogLevel to test. |
Returns
Log(LogLevel, Exception?, string?, params object?[])
Writes a message to the logger with the given LogLevel.
public virtual void Log(LogLevel logLevel, Exception? exception, string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
logLevel | LogLevel | The level of logging associated with the message. |
exception | Exception | The Exception, if any, associated with the message. |
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
Log(LogLevel, Func<string?>)
Writes data to the logger with the given LogLevel.
public void Log(LogLevel logLevel, Func<string?> messageFactory)
Parameter | Type | Description |
---|---|---|
logLevel | LogLevel | The level of logging associated with the message. |
messageFactory | Func<string> | The function that is invoked to generate the message. |
Log(LogLevel, Func<string?>, Exception?)
Writes data to the logger with the given LogLevel.
public abstract void Log(LogLevel logLevel, Func<string?> messageFactory, Exception? exception)
Parameter | Type | Description |
---|---|---|
logLevel | LogLevel | The level of logging associated with the message. |
messageFactory | Func<string> | The function that is invoked to generate the message. |
exception | Exception | The Exception, if any, associated with the message. |
Log(LogLevel, string?, params object?[])
Writes a message to the logger with the given LogLevel.
public void Log(LogLevel logLevel, string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
logLevel | LogLevel | The level of logging associated with the message. |
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogCritical(Exception?, string?, params object?[])
Writes a message to the logger with a level of Critical.
public void LogCritical(Exception? exception, string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
exception | Exception | The Exception, if any, associated with the message. |
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogCritical(Func<string?>)
Writes a message to the logger with a level of Critical.
public void LogCritical(Func<string?> messageFactory)
Parameter | Type | Description |
---|---|---|
messageFactory | Func<string> | The function to be invoked that will return the message to be logged. |
LogCritical(string?, params object?[])
Writes a message to the logger with a level of Critical.
public void LogCritical(string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogDebug(Exception?, string?, params object?[])
Writes a message to the logger with a level of Debug.
[Conditional("DEBUG")]
public void LogDebug(Exception? exception, string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
exception | Exception | The Exception, if any, associated with the message. |
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogDebug(Func<string?>)
Writes a message to the logger with a level of Debug.
[Conditional("DEBUG")]
public void LogDebug(Func<string?> messageFactory)
Parameter | Type | Description |
---|---|---|
messageFactory | Func<string> | The function to be invoked that will return the message to be logged. |
LogDebug(string?, params object?[])
Writes a message to the logger with a level of Debug.
[Conditional("DEBUG")]
public void LogDebug(string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogError(Exception?, string?, params object?[])
Writes a message to the logger with a level of Error.
public void LogError(Exception? exception, string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
exception | Exception | The Exception, if any, associated with the message. |
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogError(Func<string?>)
Writes a message to the logger with a level of Error.
public void LogError(Func<string?> messageFactory)
Parameter | Type | Description |
---|---|---|
messageFactory | Func<string> | The function to be invoked that will return the message to be logged. |
LogError(string?, params object?[])
Writes a message to the logger with a level of Error.
public void LogError(string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogInformation(Exception?, string?, params object?[])
Writes a message to the logger with a level of Information.
public void LogInformation(Exception? exception, string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
exception | Exception | The Exception, if any, associated with the message. |
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogInformation(Func<string?>)
Writes a message to the logger with a level of Information.
public void LogInformation(Func<string?> messageFactory)
Parameter | Type | Description |
---|---|---|
messageFactory | Func<string> | The function to be invoked that will return the message to be logged. |
LogInformation(string?, params object?[])
Writes a message to the logger with a level of Information.
public void LogInformation(string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogTrace(Exception?, string?, params object?[])
Writes a message to the logger with a level of Trace.
[Conditional("DEBUG")]
public void LogTrace(Exception? exception, string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
exception | Exception | The Exception, if any, associated with the message. |
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogTrace(Func<string?>)
Writes a message to the logger with a level of Trace.
[Conditional("DEBUG")]
public void LogTrace(Func<string?> messageFactory)
Parameter | Type | Description |
---|---|---|
messageFactory | Func<string> | The function to be invoked that will return the message to be logged. |
LogTrace(string?, params object?[])
Writes a message to the logger with a level of Trace.
[Conditional("DEBUG")]
public void LogTrace(string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogWarning(Exception?, string?, params object?[])
Writes a message to the logger with a level of Warning.
public void LogWarning(Exception? exception, string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
exception | Exception | The Exception, if any, associated with the message. |
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
LogWarning(Func<string?>)
Writes a message to the logger with a level of Warning.
public void LogWarning(Func<string?> messageFactory)
Parameter | Type | Description |
---|---|---|
messageFactory | Func<string> | The function to be invoked that will return the message to be logged. |
LogWarning(string?, params object?[])
Writes a message to the logger with a level of Warning.
public void LogWarning(string? message, params object?[] args)
Parameter | Type | Description |
---|---|---|
message | string | The format of the message be written. |
args | object[] | The optional values to be used when formatting the message. |
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()