Common Logging 2.0 API Reference

LogManager Class

Use the LogManager's GetLogger or GetLogger methods to obtain ILog instances for logging.

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

System.Object
   LogManager

[Visual Basic]
Public Shared Class LogManager
[C#]
public static class LogManager

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

For configuring the underlying log system using application configuration, see the example at ConfigurationSectionHandler. For configuring programmatically, see the example section below.

Example

The example below shows the typical use of LogManager to obtain a reference to a logger and log an exception:

ILog log = LogManager.GetLogger(this.GetType());
...
try 
{ 
  /* .... */ 
}
catch(Exception ex)
{
  log.ErrorFormat("Hi {0}", ex, "dude");
}

The example below shows programmatic configuration of the underlying log system:
// create properties
NameValueCollection properties = new NameValueCollection();
properties["showDateTime"] = "true";

// set Adapter
Common.Logging.LogManager.Adapter = new 
Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(properties);

Requirements

Namespace: Common.Logging

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

See Also

LogManager Members | Common.Logging Namespace | ILog | Adapter | ILoggerFactoryAdapter | ConfigurationSectionHandler