Console target

Julian Verdurmen edited this page Nov 24, 2016 · 11 revisions
Clone this wiki locally

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

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 Default: false

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