• 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“

  • 相关阅读:
    ARM处理器
    进程和线程通俗理解
    const与指针
    字符提取命令
    ThinkPHP之视图模版的使用
    ThinkPHP之MVC与URL访问
    ThinkPHP之项目搭建
    android之文件存储和读取
    cryptdb中wrapper.lua的分析
    cryptDB安装分析
  • 原文地址:https://www.cnblogs.com/94cool/p/14785735.html
Copyright © 2020-2023  润新知