Reputation: 719
I am beginner with NLog.
I want to save 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 line numbers in log file.
Upvotes: 3
Views: 1937
Reputation: 139768
You can add the numbering in the layout property of the target. There is a built in layout renderer for counting called ${counter}
<target xsi:type="File"
name="file"
fileName="logfile.txt"
layout="${counter} ${longdate}|${level:uppercase=true}|${logger}|${message}"/>
Upvotes: 4