Log Targets

Targets represents possible log outputs. You can define one or more targets in the configuration file with the directive. When defining a target you need to specify its name and type.

The following types of targets are supported by NLog:

  • Regular Targets - which write the log messages to some output
  • Target Wrappers - which modify the behaviour of a target by adding features such as asynchronous processing, buffering, filtering and so on.
  • Compound Targets - which route the log messages to one or more attached targets - they can be used to provide failover, load balancing, log splitting and so on

Regular Targets

Regular targets are responsible for writing log output to persistent media, such as files, databases, network receivers or message queues. Each target has its own set of type-specific configuration parameters which are passed as XML attributes or elements.

The following example defines a single file target with a file name of 'file.txt':

                <targets> 
    <target name="n" type="File" fileName="file.txt"/> 
</targets>  

The following log targets are available. Click on a target name for a reference of possible target parameters.

Target Wrappers

Target wrappers are used to modify the behavior of other targets by adding features such as:

  • asynchronous processing (wrapped target runs in a separate thread)
  • retry-on-error
  • buffering

The following target wrappers are available. Click on a target name for full reference.

Compound Targets

The following compound targets are available. Click on the target name for full reference.

Target


Remarks:

Parameters (blue fields are required):

Name Type Description

Example:


Back to the target list.
Collection of . Each element is represented as </>
Name Type Description