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

NLOG配置

时间:2016-11-06 16:56:49      阅读:812      评论:0      收藏:0      [点我收藏+]

标签:level   for   top   private   inf   filename   tom   路径   schema   

<?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">

<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!-- add your targets here -->

<!--
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
<!--说明:
xsi:type="File"指定输出到文件类型;
name ="file_info"指定target的名字;
fileName="${basedir}/Logs/NlogBlog_${level}_${shortdate}.txt"指定输出文件的具体名。
其中${basedir}的意思是程序所在的路径; ${level}的意思是日志的等级; ${shortdate}的意思是日期(具体到日)"
layout="${longdate} ${message}"指定输出文件内容的样式(可自由定义);
其中${longdate}的意思是日期(具体到毫秒),${message}是你具体要输出的内容。
-->
<target xsi:type="File" name ="file_info" fileName="${basedir}/Logs/NlogBuyLimit_${level}_${shortdate}.txt"
layout="${longdate} ${message}" encoding="UTF-8"/>
<target xsi:type="File" name ="file_info1" fileName="${basedir}/Logs/NlogBuyStop_${level}_${shortdate}.txt"
layout="${longdate} ${message}" encoding="UTF-8"/>
<target xsi:type="File" name ="file_info2" fileName="${basedir}/Logs/NlogSellLimit_${level}_${shortdate}.txt"
layout="${longdate} ${message}" encoding="UTF-8"/>
<target xsi:type="File" name ="file_info3" fileName="${basedir}/Logs/NlogSellStop_${level}_${shortdate}.txt"
layout="${longdate} ${message}" encoding="UTF-8"/>


<target xsi:type="File" name ="file_debug" fileName="${basedir}/Logs/NlogBlog_${level}_${shortdate}.txt"
layout="${longdate} ${message}" encoding="UTF-8"/>
<target xsi:type="File" name ="file_warn" fileName="${basedir}/Logs/NlogBlog_${level}_${shortdate}.txt"
layout="${longdate} ${message}" encoding="UTF-8"/>
<target xsi:type="File" name ="file_error" fileName="${basedir}/Logs/NlogBlog_${level}_${shortdate}.txt"
layout="${longdate} ${message}" encoding="UTF-8"/>
<target xsi:type="File" name ="file_trace" fileName="${basedir}/Logs/NlogBlog_${level}_${shortdate}.txt"
layout="${longdate} ${message}" encoding="UTF-8"/>

</targets>

<rules>
<!-- add your logging rules here -->

<!--
<logger name="*" minlevel="Trace" writeTo="f" />
-->
<logger name="A" levels="Info" writeTo="file_info"/>
<logger name="B" levels="Info" writeTo="file_info1"/>
<logger name="C" levels="Info" writeTo="file_info2"/>
<logger name="D" levels="Info" writeTo="file_info3"/>
<logger name="*" levels="Debug" writeTo="file_debug"/>
<logger name="*" levels="Warn" writeTo="file_warn"/>
<logger name="*" levels="Error" writeTo="file_error"/>
<logger name="*" levels="Trace" writeTo="file_trace"/>
</rules>
</nlog>

 

  private static NLog.Logger BuyLimitLog = NLog.LogManager.GetLogger("A");

NLOG配置

标签:level   for   top   private   inf   filename   tom   路径   schema   

原文地址:http://www.cnblogs.com/zhangyuefen/p/6035278.html

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