NLog:FormControl目标真的存在吗?

时间:2015-10-22 12:32:34

标签: nlog

根据the documentation,NLog提供了一个FormControl目标,它将日志消息写入Windows窗体上控件的Text属性中。但是,当我向我的配置添加一个FormControl目标时,我得到一个异常,告诉我没有名为" FormControl"的目标存在。我确实下载了NLog.Windows.Forms包,并在我的项目中包含了对DLL的引用。

以下是配置:

<?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"
      throwExceptions="true">

  <!-- 
  See https://github.com/nlog/nlog/wiki/Configuration-file 
  for information on customizing logging rules and outputs.
   -->
  <targets>
    <!--
    <target xsi:type="File" name="FileTarget" fileName="${basedir}/NLogger_4_1_2.log"
            layout="${date} ${uppercase:${level}} ${message}" />
    -->
    <target name="AsyncTarget" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
      <target xsi:type="File" name="FileTarget1" fileName="${basedir}/NLogger_4_1_2.log"
              layout="${date} ${uppercase:${level}} ${message}" />
    </target>
    <target xsi:type="File" name="ReportTarget" fileName="${basedir}/NLogger_4_1_2_report.log"
            layout="${date} ${uppercase:${level}} ${message}" />
    <target xsi:type="FormControl"
            name="FormControlTarget"
            layout="${message}"
            append="true"
            controlName="TextBox1"
            formName="Form1" />

  </targets>

  <rules>
    <logger name="FileLogger" minlevel="Trace"
            writeTo="AsyncTarget" />
    <logger name="ReportLogger" minlevel="Trace"
            writeTo="ReportTarget" />
    <logger name="FormLogger" minlevel="Trace"
            writeTo="FormControlTarget" />
  </rules>
</nlog>

0 个答案:

没有答案