NLog配置分享
<?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"> <targets> <target name="asyncFile" xsi:type="AsyncWrapper"> <target name="info_file" xsi:type="File" fileName="${basedir}/Logs/${date:format=yyyyMM}/Info/Info.${shortdate}.log" layout="${longdate} | ${message} ${onexception:${exception:format=message} ${newline} ${stacktrace} ${newline}}" archiveFileName="${basedir}/Logs/${date:format=yyyyMM}/Info.${shortdate}-{#####}.log" archiveAboveSize="102400" archiveNumbering="Sequence" concurrentWrites="true" keepFileOpen="false" /> <target name="err_file" xsi:type="File" fileName="${basedir}/Logs/${date:format=yyyyMM}/Error/Error.${shortdate}.log" layout="${longdate} | ${message} ${onexception:${exception:format=message} ${newline} ${stacktrace} ${newline}}" archiveFileName="${basedir}/Logs/${date:format=yyyyMM}/Error.${shortdate}-{#####}.log" archiveAboveSize="102400" archiveNumbering="Sequence" concurrentWrites="true" keepFileOpen="false" /> </target> <target name="console" xsi:type="ColoredConsole" layout="[${date:format=HH\:mm\:ss}]:${message} ${exception:format=message}" /> </targets> <rules> <logger name="*" minlevel="Info" writeTo="info_file" /> <logger name="*" minlevel="Error" writeTo="err_file" /> <logger name="*" minlevel="Debug" writeTo="console" /> </rules> </nlog> <!-- public static Logger logger = LogManager.GetCurrentClassLogger(); -->