Table of Contents

Class Log4NetLogger

Namespace
Splat.Log4Net
Assembly
Splat.Log4Net.dll

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

inner ILog

The 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

exception Exception

The exception that occurred.

message string

The message to write.

logLevel LogLevel

The 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

exception Exception

The exception that occurred.

message string

The message to write.

type Type

The type associated with the log message.

logLevel LogLevel

The severity level of the log message.

Write(string, LogLevel)

Writes a message to the target.

public void Write(string message, LogLevel logLevel)

Parameters

message string

The message to write.

logLevel LogLevel

The 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)

Parameters

message string

The message to write.

type Type

The type associated with the log message.

logLevel LogLevel

The severity level of the log message.