NLog :: setting the line number in the log file

I am starting with NLog.

I want to store the line number along with my log entry.

1 <log content>
2 <log content>
3 <log content>
4 <log content>
.............
...........
n <log content>

      

where 1,2,3, .... n are the line numbers in the log file.

+3


source to share


1 answer


You can add numbering in the object's layout property. There is a built -in render layout for counting the names of $ {counter}



<target xsi:type="File" 
   name="file" 
   fileName="logfile.txt"
   layout="${counter} ${longdate}|${level:uppercase=true}|${logger}|${message}"/>

      

+4


source







All Articles