码迷,mamicode.com
首页 > 其他好文 > 详细

常用NLog配置

时间:2018-06-24 11:42:24      阅读:984      评论:0      收藏:0      [点我收藏+]

标签:color   mat   get   style   encoding   bug   ddr   conf   ted   

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   
    <configSections>
      <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
    </configSections>
  
    <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <targets>
        <target name="file" xsi:type="File"
            layout="${longdate} ${logger} ${message}${exception:format=ToString}"
            fileName="${basedir}/logs/${shortdate}.log"
            keepFileOpen="true"
            encoding="utf-8" />
        <target name="f1" xsi:type="File" fileName="file1.txt"/>
        <!--layout代表日志的格式-->
        <target name="f2" xsi:type="File" fileName="file2.txt" layout="${date:format=yyyyMMddHHmmss} ${callsite} ${level} ${message}"/>
        <target name="n1" xsi:type="Network" address="tcp://localhost:4001"/>
        <target name="ds" xsi:type="OutputDebugString"/>
      </targets>

      <rules>
        <!--writeTo使用哪个target-->
        <logger name="*" minlevel="Debug" writeTo="f2" />
        <logger name="mylog" minlevel="Debug" writeTo="f1" />
        <logger name="test" levels="Debug,Error" writeTo="n1"/>
      </rules>
    </nlog>


  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>

</configuration>

直接复制 ,更改writeTo属性就 可以 使用。

常用NLog配置

标签:color   mat   get   style   encoding   bug   ddr   conf   ted   

原文地址:https://www.cnblogs.com/zhaotianff/p/9219660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!