Common Logging 2.0 API Reference

ILog Interface

A simple logging interface abstracting logging APIs.

For a list of all members of this type, see ILog Members .

[Visual Basic]
Public Interface ILog
[C#]
public interface ILog

Types that implement ILog

Type Description
EntLibLogger Concrete implementation of ILog interface specific to Enterprise Logging 4.1.
EntLibLogger Concrete implementation of ILog interface specific to Enterprise Logging 3.1.
AbstractLogger Provides base implementation common for most logger adapters
Log4NetLogger Concrete implementation of ILog interface specific to log4net 1.2.9.
Log4NetLogger Concrete implementation of ILog interface specific to log4net 1.2.10.
NLogLogger Concrete implementation of ILog interface specific to NLog 1.0.0.505.
AbstractSimpleLogger Abstract class providing a standard implementation of simple loggers.
CapturingLogger A logger created by CapturingLoggerFactoryAdapter that sends all log events to the owning adapter's AddEvent
ConsoleOutLogger Sends log messages to Out.
NoOpLogger Silently ignores all log messages.
TraceLogger Logger sending everything to the trace output stream using Trace.

Remarks

Implementations should defer calling a message's ToString until the message really needs to be logged to avoid performance penalties.

Each ILog log method offers to pass in a Action`1 instead of the actual message. Using this style has the advantage to defer possibly expensive message argument evaluation and formatting (and formatting arguments!) until the message gets actually logged. If the message is not logged at all (e.g. due to LogLevel settings), you won't have to pay the peformance penalty of creating the message.

Example

The example below demonstrates using callback style for creating the message, where the call to the NextDouble and the underlying Format only happens, if level Debug is enabled:

Log.Debug( m=>m("result is {0}", random.NextDouble()) );
Log.Debug(delegate(m) { m("result is {0}", random.NextDouble()); });

Requirements

Namespace: Common.Logging

Assembly: Common.Logging (in Common.Logging.dll)

See Also

ILog Members | Common.Logging Namespace | Action`1