Skip to content
Rolf Kristensen edited this page Apr 21, 2026 · 21 revisions

Writes log messages to the attached managed debugger (Ex. Visual Studio Output Window). See also System.Diagnostics.Debugger.Log

Platforms Supported: All

Configuration Syntax

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

Read more about using the Configuration File.

Parameters

  • name - Name of the target.
  • layout - Text to be rendered. Layout Required. Default: ${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}
  • header - Layout used to format header-output when initializing.
  • footer - Layout used to format footer-output when closing.
  • Category - Layout used to format the category. Default: ${logger}

    Introduced with NLog v6.1

  • MaxMessageSize - Max message length in characters before applying OnOverflow-action (0 means unlimited) . Default: 0.

    Introduced with NLog v6.1

  • OnOverflow - Action to perform when max message size is exceeded. Default: Split

    Introduced with NLog v6.1

    • Truncate - Truncate the message to fit.
    • Split - Split the big message into multiple log messages.
    • Discard - Discard the entire message.

Examples

From stackoverflow

<targets>
  <target name="debugger" xsi:type="Debugger" layout="${level}|${message:withException=true}"/>
</targets>

<rules>
  <logger name="*" minlevel="Trace" writeTo="debugger" />
</rules>

Notes

Alternative targets for diagnostic output:

Clone this wiki locally