前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >NLog配置分享

NLog配置分享

作者头像
晓晨
发布2018-06-22 15:42:37
7150
发布2018-06-22 15:42:37
举报
文章被收录于专栏:晓晨的专栏

新建一个文件命名为NLog.Config,然后添加如下代码

代码语言:javascript
复制
<?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">

  <targets>
    <target name="asyncFile" xsi:type="AsyncWrapper">
      <target name="log_file" xsi:type="File"
              fileName="${basedir}/Logs/${shortdate}/${shortdate}.txt"
              layout="${longdate} | ${message} ${onexception:${exception:format=message} ${newline} ${stacktrace} ${newline}"
              archiveFileName="${basedir}/archives/${shortdate}-{#####}.txt"
              archiveAboveSize="102400"
              archiveNumbering="Sequence"
              concurrentWrites="true"
              keepFileOpen="false" />
    </target>
    <target name="console" xsi:type="ColoredConsole" layout="[${date:format=HH\:mm\:ss}]:${message} ${exception:format=message}" />
  </targets>

  <rules>
    <logger name="*" minlevel="Error" writeTo="asyncFile" />
    <logger name="*" minlevel="Debug" writeTo="console" />
  </rules>
</nlog>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-03-04 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档