Skip to content

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.

Parameters

  • TimestampFormat - Override the format to output the LogEvent Timestamp. Default (null) means skip timestamp. Can be any argument accepted by DateTime.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

Notes

Clone this wiki locally