zoukankan      html  css  js  c++  java
  • 【.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>
    
  • 相关阅读:
    vue3学习笔记
    学习笔记-Python-爬虫5-Selenium + PhantomJS
    学习笔记-Python-爬虫4-数据提取-正则、XML、XPath、BeautifulSoup4
    学习笔记-Python-爬虫7-Scrapy、分布式爬虫
    学习笔记-Python-爬虫6-验证码
    学习笔记-Python-爬虫3-requests
    学习笔记-Python-爬虫2-SSL、js加密、ajax
    学习笔记-Python-爬虫1-urllib、chardet
    Java多线程同步问题
    jQuery限制文本框只能输入正整数
  • 原文地址:https://www.cnblogs.com/zhuzhongxing/p/14147092.html
Copyright © 2011-2022 走看看