Skip to content

Instantly share code, notes, and snippets.

@MinChanSike
Last active May 24, 2019 10:11
Show Gist options
  • Save MinChanSike/b33b85c7dca81c43f198797f4f49ce26 to your computer and use it in GitHub Desktop.
Save MinChanSike/b33b85c7dca81c43f198797f4f49ce26 to your computer and use it in GitHub Desktop.
NLog configuration to export as file
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true">
<variable name="defaultLayout" value="${longdate}|${uppercase:${level}}|${logger}|${message}${onexception:${newline}${exception:format=tostring}}" />
<targets>
<target xsi:type="File" name="File" fileName="${basedir}/logs/WebAppAuth.log"
archiveEvery="Day"
archiveDateFormat="yyyy-MM-dd"
archiveNumbering="Date"
maxArchiveFiles ="365"
concurrentWrites="true"
keepFileOpen="false">
<layout xsi:type="CsvLayout">
<quoting>Auto</quoting>
<withHeader>true</withHeader>
<delimiter>Tab</delimiter>
<column name="DateTime" layout="${longdate}" />
<column name="Serverity" layout="${uppercase:${level}}" />
<column name="Category" layout="${logger}" />
<column name="Message" layout="${message}" />
<column name="Exception" layout="${exception:format=tostring}" />
</layout>
</target>
<target xsi:type="Debugger" name="Debugger" layout="${defaultLayout}" />
<target xsi:type="Console" name ="Console" layout="${defaultLayout}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo ="File,Console"/>
</rules>
</nlog>
@MinChanSike
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment