zoukankan      html  css  js  c++  java
  • 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“

  • 相关阅读:
    面向对象设计原则
    简单工厂模式和策略模式结合使用php
    lua string
    js.ajax优缺点,工作流程
    深入理解JavaScript是如何实现继承的
    js中哈希表的几种用法总结
    js,indexOf()、lastIndexOf()
    js获取字符串字节数方法小结
    JS(JavaScript)插入节点的方法appendChild与insertBefore
    js中的this关键字详解
  • 原文地址:https://www.cnblogs.com/94cool/p/14785735.html
Copyright © 2011-2022 走看看