NLog has many targets to which it can save log entries. Here are some that I consider quite useful.
File
1 2 3 4 5 6 7 8 |
<target name="logfile" xsi:type="File" fileName="${basedir}/logs/current.log" archiveFileName="${basedir}/logs/${shortdate}.{#}.log" archiveAboveSize="5242880" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="0" /> |
I’ve added some parameters to archive log on everyday basis.
EventLog
1 2 3 4 5 |
<target name="eventlog" xsi:type="EventLog" log="MyAppLog" source="MyAppLog" layout="${message}${newline}${exception:format=ToString}"/> |
NLog will create custom application log MyAppLog.
Visual Studio Debug window
1 2 3 |
<target name="debugger" xsi:type="Debugger" layout="${logger}::${message}"/> |
Also NLog allows to save log in a database table, but it needs more efforts and lines of code to setup it. You can read more in the article Database target in NLog project documentation.