5

Is it possible to include a carriage-return and or linefeed in an NLog layout. I wish to hold the following format of header information in all my logs:

    Application Name: <Application Name> 
    File Version: <Version number>
    Released:  <Release date>
    User: <Windows User>
    etc...

    21|17:07:54|domain\user|Trace|  System.OverflowException: Arithmetic operation
         resulted in an overflow at application.form.Button1_Click(Object sender,
         EventArgs e) in D:\Documents and    
         Settings\user\Mydocuments\workarea\application\application
         project\application.vb:line 47

All assistance much appreciated

Regards

Paul J.

Paul Johnson
  • 213
  • 3
  • 14

1 Answers1

10

NLog has a ${newline} LayoutRenderer that will add a newline to the output.

If you want the "header" to only appear once in the log file (or once per run), you might want to see this question as well:

Nlog - Generating Header Section for a log file

This answer also describes adding a header to an NLog log file:

https://stackoverflow.com/a/4259447/125439

Community
  • 1
  • 1
wageoghe
  • 27,390
  • 13
  • 88
  • 116