• 【.NET / C#】NLog.config


    <?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"
          xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
          autoReload="true" throwExceptions="false">
    
      <variable name="log.path" value="D:/logs/"/>
      <variable name="log.name" value="ApplicationName"/>
      <variable name="log.pattern" value="[${longdate}] [${level:uppercase=true:padding=-5}] [${threadid}] [${logger}] ${message}"/>
      <variable name="log.file" value="${level}_${log.name}.log"/>
      <variable name="log.archive" value="${date:format=MM}/${date:format=dd}/${level}_${log.name}_{##}.log"/>
      
      <targets async="true">
        <!--保存至文件-->
        <target name="log" xsi:type="AsyncWrapper">
          <target xsi:type="File"
                fileName="${log.path}${log.name}/${log.file}"
                layout="${log.pattern}"
                archiveFileName="${log.path}${log.name}/${log.archive}"
                archiveEvery="Day"
                archiveAboveSize="104857600"
                archiveNumbering="DateAndSequence"
                archiveDateFormat="yyyyMMdd"
                concurrentWrites="true"
                maxArchiveFiles="99"
                encoding="UTF-8"
                keepFileOpen="false" />
        </target>
        
        <!--输出至控制台-->
        <!--
        <target name="console" xsi:type="AsyncWrapper">
          <target xsi:type="ColoredConsole"
                  layout="[${level:uppercase=true:padding=-5}] [${date:format=yyyy-MM-dd HH:mm:ss,fff}] [${message}] ${newline}" >
            <highlight-row condition="level == LogLevel.Trace" foregroundColor="Gray" />
            <highlight-row condition="level == LogLevel.Debug" foregroundColor="White" />
            <highlight-row condition="level == LogLevel.Info" foregroundColor="Green" />
            <highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
            <highlight-row condition="level == LogLevel.Error" foregroundColor="Magenta" />
            <highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" />
          </target>
        </target>
        -->
        
        <!--输出至Debugger-->
        <!--
        <target name="debugger" xsi:type="AsyncWrapper">
          <target xsi:type="Debugger"
                  layout="NLog: ${shorttime} > ${message}" />
        </target>
        -->
      </targets>
    
      <rules>
        <logger name="*" minlevel="Trace" writeTo="log" />
        <!--<logger name="*" minlevel="Debug" writeTo="console" />-->
        <!--<logger name="*" minlevel="Debug" writeTo="debugger" />-->
      </rules>
      
    </nlog>
    
  • 相关阅读:
    poj 3617 Best Cow Line
    POJ 1852 Ants
    Pairs
    codility MinAbsSum
    Codeforces Beta Round #67 (Div. 2)C. Modified GCD
    timus 1018. Binary Apple Tree
    C
    HDU 1299Diophantus of Alexandria
    BZOJ2155(?) R集合 (卡特兰数)
    CSP模拟赛 number (二分+数位DP)
  • 原文地址:https://www.cnblogs.com/zhuzhongxing/p/14147092.html
Copyright © 2020-2023  润新知