NLog how to wirte to console and file at the sam etime code example
Example 1: NLog how to wirte to console and file at the sam etime
<logger name="*" minlevel="Debug" writeTo="console" />
<logger name="*" minlevel="Debug" writeTo="debugger" />
<logger name="*" minlevel="Debug" writeTo="FullCSVFile" />
Example 2: NLog how to wirte to console and file at the sam etime
<target name="debugger" xsi:type="Debugger" layout="${level}>${message} (${exception:format=ToString})"/>
<target name="console" xsi:type="ColoredConsole" layout="${date:format=dd-MM-yyyy HH\:mm\:ss} - ${message}" />
<target name="FullCSVFile" xsi:type="File" fileName="${specialfolder:folder=LocalApplicationData}\YourApp\YourApp-${date:format=yyyy-MM-dd}.csv">
<layout xsi:type="CsvLayout">
<column name="Index" layout="${counter}" />
<column name="ThreadID" layout="${threadid}" />
<column name="Time" layout="${longdate}" />
<column name="Severity" layout="${level:uppercase=true}" />
<column name="Location" layout="${callsite:className=False:fileName=True:includeSourcePath=False:methodName=False}" />
<column name="Detail" layout="${message}" />
<column name="Exception" layout="${exception:format=ToString}" />
</layout>
</target>