Skip to content
Rolf Kristensen edited this page Oct 23, 2023 · 19 revisions

Sends log messages through System.Diagnostics.Trace.

Platforms Supported: Limited (Not available for NetStandard1.3)

Configuration Syntax

<targets>
  <target xsi:type="Trace" name="String" layout="Layout" />
</targets>

Parameters

General Options

  • name - Name of the target.

Output Options

  • layout - Layout used to format log messages. Layout Required. Default: ${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}
  • rawWrite - Always use Trace.WriteLine independent of LogLevel. Default: False

    Introduced with NLog 4.5, fixes the issue with output being prefixed with exe-filename.

  • EnableTraceFail - Use Trace.Fail for LogLevel.Fatal, instead of Trace.Error. Default: 'False'

    Introduced with NLog 4.7, avoids Enviroment.FailFast that can happen for default trace listener.

  • header - Layout used to format header-output when initializing. Layout

    Introduced with NLog 5.0

  • footer - Layout used to format footer-output when closing. Layout

    Introduced with NLog 5.0

Notes

Alternative targets for diagnostic output:

Clone this wiki locally