LAUREL BRIDGE

NLogLogAdapter Class

DICOM Connectivity Framework V3.4
Adapter class to support using NLog as the back end log client.
Inheritance Hierarchy

SystemObject
  LaurelBridge.DCF.Examples.NLogAdapterNLogLogAdapter

Namespace:  LaurelBridge.DCF.Examples.NLogAdapter
Assembly:  ExampleNLogAdapter (in ExampleNLogAdapter.dll) Version: DCF34 r10560 DCF_3_4_10
Syntax

C#
public class NLogLogAdapter : IDisposable

The NLogLogAdapter type exposes the following members.

Constructors

  NameDescription
Public methodNLogLogAdapter
Constructor that configures NLog using the input path to the desired nlog configuration xml file.
Top
Properties

  NameDescription
Public propertyFormatProvider
Get/Set the format provider to use when logging messages to nlog.
Top
Methods

  NameDescription
Public methodDebug
Log a debug level message to the logging backend.
Public methodDebugFormat
Log a debug level message to the logging backend.
Public methodDispose
Flush any pending buffered log messages and cleanup logger resources.
Public methodError
Log an error level message to the logging backend.
Public methodErrorFormat
Log an error level message to the logging backend.
Public methodFatal
Log a fatal level message to the logging backend.
Public methodFatalFormat
Log a fatal level message to the logging backend.
Public methodFlush
Flush any pending buffered log messages. The implementation of this method is defined by the LogAdapter.
Public methodInfo
Log an info level message to the logging backend.
Public methodInfoFormat
Log an info level message to the logging backend.
Public methodReconfigureLogDirectory
Reconfigures the output log directory for the file logger.
Public methodVerbose
Log a verbose level message to the logging backend.
Public methodVerboseFormat
Log a verbose level message to the logging backend.
Public methodWarn
Log a warn level message to the logging backend.
Public methodWarnFormat
Log a warn level message to the logging backend.
Top
Remarks

This example is used to create demonstrate how to write an ILogAdapter for NLog to customize DCF logging behavior. This adapter creates a single NLog.Logger for all log messages fielded from the DCF libary. An alternate implementation might create a logger for each calling class by getting the NLog logger for the ILogger.Name on each ILogger method call.

Each DCF ILogger call passes a LogEvent that contains the log message, arguments, exception, and session information. This adapter takes the information in the DCF LogEvent and converts it to an NLog LogEventInfo. This allows the properties in the DCF LogEvent to be accessible within the NLog configuration.

The NLog binaries for this example were downloaded from: http://nlog-project.org.
This adapter class was written using NLog v4.1.2.

See Also

Reference