Class Log4NetLogger
Provides an implementation of the ILogger interface that writes log messages using a wrapped Log4Net logger instance.
public sealed class Log4NetLogger : ILogger, IDisposable
- Inheritance
-
Log4NetLogger
- Implements
-
ILogger
- Extension Methods
Remarks
This class enables integration of Log4Net logging with components that consume the ILogger abstraction. The effective log level is determined from the underlying Log4Net configuration and is updated automatically if the configuration changes. Instances of this class are not thread-safe for disposal; ensure that Dispose is not called concurrently with logging operations.
Constructors
Log4NetLogger(ILog)
Initializes a new instance of the Log4NetLogger class.
public Log4NetLogger(ILog inner)
Parameters
innerILogThe Log4Net logger instance to wrap.
Exceptions
- ArgumentNullException
Thrown when the Log4Net logger is null.
Properties
Level
Gets the level at which the target will emit messages.
public LogLevel Level { get; }
Property Value
- LogLevel
Methods
Dispose()
public void Dispose()
Write(Exception, string, LogLevel)
Writes a message to the target.
public void Write(Exception exception, string message, LogLevel logLevel)
Parameters
exceptionExceptionThe exception that occurred.
messagestringThe message to write.
logLevelLogLevelThe severity level of the log message.
Write(Exception, string, Type, LogLevel)
Writes a message to the target.
public void Write(Exception exception, string message, Type type, LogLevel logLevel)
Parameters
exceptionExceptionThe exception that occurred.
messagestringThe message to write.
typeTypeThe type associated with the log message.
logLevelLogLevelThe severity level of the log message.
Write(string, LogLevel)
Writes a message to the target.
public void Write(string message, LogLevel logLevel)
Parameters
messagestringThe message to write.
logLevelLogLevelThe severity level of the log message.
Write(string, Type, LogLevel)
Writes a message to the target.
public void Write(string message, Type type, LogLevel logLevel)