Console target

michael-freidgeim-webjet edited this page Mar 22, 2018 · 19 revisions

Writes log messages to the console.

Supported in .NET, Silverlight, Compact Framework and Mono

Configuration Syntax

<targets>
  <target xsi:type="Console"
          name="String"
          layout="Layout"
          footer="Layout"
          header="Layout"
          encoding="Encoding"
          error="Boolean"
          detectConsoleAvailable="Boolean" />
</targets>

Read more about using the Configuration File.

Parameters

General Options

  • name - Name of the target.

Layout Options

  • layout - Text to be rendered. Layout Required. Default: ${longdate}|${level:uppercase=true}|${logger}|${message}
  • footer - Footer. Layout
  • header - Header. Layout

Performance Options

  • OptimizeBufferReuse - Reduce logging overhead, by allowing buffer reuse. Default: True

    Introduced with NLog v4.4.2. Default became True with NLog v4.5

Console Options

  • encoding - File encoding name like "utf-8", "ascii" or "utf-16". See Encoding class on MSDN. Defaults to Encoding.Default (UTF-8 on silverlight). Starting for NLog 4.0.

  • error - Indicates whether to send the log messages to the standard error instead of the standard output. [Boolean](Data types) Default: false

  • detectConsoleAvailable - Indicates whether the console target should disable itself when no console detected. [Boolean](Data types) Default: false (introduced in 4.3.10 with default: true. Since NLog 4.4 default false)

Example

<target name="Console" xsi:type="Console" layout="${longdate} ${callsite} ${level} ${message}"/>

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.