Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include carriage-return linefeed in NLog Layout

Tags:

vb.net

nlog

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.

like image 518
Paul Johnson Avatar asked Sep 25 '13 16:09

Paul Johnson


1 Answers

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

like image 134
wageoghe Avatar answered Sep 20 '22 17:09

wageoghe