Creating Logging Channels
A Logging Channel is an object that listens for log messages and processes them. The Leadtools.Logging assembly provides several default implementations of logging channels. To create your own logging channel, you must create a class that implements ILoggingChannel. If you don't want to completely re-implement ILoggingChannel, then you can create a new class that derives from the LoggingChannel base class instead.
Logging Messages
Logging messages consists of sending log entries to the registered log channels. If you want log a specific log entry type you can call one of the Logger specific methods:
For more control over the log entry, you can use the Logger.Log method to send a LogEntry item. If you require custom information use the LogEntry.CustomInformation dictionary.
Logging DICOM Messages
If you want to log DICOM specific messages use Leadtools.Logging.Medical.LogExtensions. A MessageDirection type is provided to allow you to specify the direction of a communication message. In addition, the DicomLogEntry class is a custom ILogEntry implementation that has additional properties specific to DICOM logging.
Configuring AppConfig for Logging
To configure logging in your App.Config file you need to first add the configuration section.
< configSections >
< section name = "logging" type="Leadtools.Logging.Configuration.ConfigSectionHandler, Leadtools.Logging" />
</ configSections >
After adding the configuration section you can begin by adding the logging section. The logging section has the following child elements.
channels | Global channels that are accessed with Logger.Global. |
loggers | Custom loggers are stored in this element. |
The <channels> element has the following child element.
channel | User specific logging channel. Multiple elements allowed. |
The <channel> element has the following attributes:
- Name - name of the logging channel
- Type - type name of the logging channel
- Enabled - whether the channel is enabled
- Property Values - any property on the channel object can be specified as an attribute
The <loggers> element has the following child element:
logger | User defined logger. Multiple elements allowed. |
The <logger> element has the following attributes:
- Name - name of the logger
The <logger> element has the following child element:
channels | List of channels associated with the logger. |