NLog 配置文件按固定大小生成多文件

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <targets>
     <target name="log" xsi:type="File" fileName="${basedir}/Log/${shortdate}_log.txt" encoding="utf-8" archiveNumbering="Sequence" archiveAboveSize="104857600"/>
     <target name="debug" xsi:type="File" fileName="${basedir}/Log/${shortdate}_debug.txt" encoding="utf-8" archiveNumbering="Sequence" archiveAboveSize="104857600"/>
     <target name="trace" xsi:type="File" fileName="${basedir}/Log/${shortdate}_trace.txt" encoding="utf-8" archiveNumbering="Sequence" archiveAboveSize="104857600"/>
     <target name="exception" xsi:type="File" fileName="${basedir}/Log/${shortdate}_exception.txt" layout="${longdate} | ${level:uppercase=false} | ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}" encoding="utf-8" archiveNumbering="Sequence" archiveAboveSize="104857600" />
     <target name="system" xsi:type="File" fileName="${basedir}/Log/system.txt" encoding="utf-8" archiveNumbering="Sequence" archiveAboveSize="104857600"></target>
   </targets>
   <rules>
     <logger name="system" level="Info" writeTo="system" />
     <logger name="*" level="Debug" writeTo="debug"/>
     <logger name="*" level="Trace" writeTo="trace"/>
     <logger name="*" level="Info" writeTo="log"/>
     <logger name="*" level="Error" writeTo="exception"/>
   </rules>  
</nlog>


参数:

文件编码:encoding="utf-8"

文件分割文件名附加数字顺序:archiveNumbering="Sequence"

文件分割文件名附加日期与数字顺序:archiveNumbering="DateAndSequence"

DateAndSequence中日期格式:archiveDateFormat="yyyyMMdd"

文件分割大小:单位=字节 archiveAboveSize="104857600“

原文地址:https://www.cnblogs.com/94cool/p/14785735.html