-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MicrosoftConsoleLayout
Rolf Kristensen edited this page Jul 28, 2023
·
7 revisions
A specialized layout that renders like default Microsoft Console Logger with Microsoft AddConsole Formatter.
Platforms Supported: All
Introduced with NLog.Extensions.Logging ver. 1.7.2
<nlog>
<targets>
<target name="lifetimeConsole" xsi:type="Console" layout="${MicrosoftConsoleLayout}" />
</targets>
<rules>
<logger name="Microsoft.Hosting.Lifetime" level="Info" writeTo="lifetimeConsole" final="true" />
</rules>
</nlog>
This would write:
info: Microsoft.Hosting.Lifetime[0]
Application started. Press CTRL-C to shut down.
-
TimestampFormat - Override the format to output the LogEvent Timestamp. Default
(null)
means skip timestamp. Can be any argument accepted byDateTime.ToString(format)
.Introduced with NLog.Extensions.Logging ver. 5.0
-
UseUtcTimestamp - Configure whether to use UTC timezone for the LogEvent Timestamp. Default
false
.Introduced with NLog.Extensions.Logging ver. 5.0
- MicrosoftConsoleJsonLayout is also available and matches Microsoft AddJsonConsole Formatter.
- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json