-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Console target
Writes log messages to the console.
Platforms Supported: All
There is also the colorful ColoredConsole-Target that can highlight single words or color entire rows.
<targets>
<target xsi:type="Console"
name="String"
layout="Layout"
footer="Layout"
header="Layout"
encoding="Encoding"
stderr="Boolean"
detectConsoleAvailable="Boolean"
writeBuffer="Boolean" />
</targets>Read more about using the Configuration File.
- name - Name of the target.
-
layout - Text to be rendered. Layout Required. Default:
${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true} - footer - Footer. Layout
- header - Header. Layout
-
encoding - File encoding name like "utf-8", "ascii" or "utf-16". See Encoding class on MSDN. Defaults to
Encoding.Default.Introduced in NLog 4.0.
-
StdErr - Indicates whether the error stream (stderr) should be used instead of the output stream (stdout). Layout Default:
falseBefore NLog v5.0 the property was named
error. Before NLog v6.0 the property was boolean instead of NLog Layout -
detectConsoleAvailable - Indicates whether the console target should disable itself when no console detected. Boolean Default:
falseIntroduced in NLog 4.3.10 with default:
true, then NLog 4.4 changed default tofalse. -
autoFlush - Performs explicit flush after every console write. Useful if having redirected to custom console-stream that doesn't has autoflush enabled. Boolean. Default = False.
Introduced in NLog 4.6.3
-
ForceWriteLine - Call
Console.WriteLineinstead of writing directly to buffer usingConsole.Write. Available if doing console-redirection that requiresConsole.WriteLine. Default:False.Before NLog v6.0 the property was named
WriteBufferwhich was introduced with v4.6.8.
<target name="Console" xsi:type="Console" layout="${longdate} ${logger} ${level} ${message}"/>- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
- Articles about NLog
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json