无法使用Nlogger for MSTest在VS Output窗口中查看日志消息

时间:2016-10-27 01:13:45

标签: c# mstest nlog

使用MSTest和NLogger我能够将消息写入日志文件,但我在VS测试资源管理器的输出窗口中不再看到消息。以下是我用于NLogger的配置。有什么帮助吗?

    <?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="true"
      internalLogLevel="Trace" internalLogFile="c:\temp\nlog-internal.log">

  <variable name="brief" value="${longdate} | ${threadid} | ${level} | ${callsite} | ${message}"/>


  <targets>
    <target name="logfile" xsi:type="File" fileName="C:\Test.log" layout="${brief}"  />
    <target name="console" xsi:type="Console" />
    <target name="debugger" xsi:type="Debugger" layout="${logger}::${message}"/>

  </targets>

  <rules>
    <logger name="*" minlevel="Info" writeTo="logfile" />
    <logger name="*" minlevel="Trace" writeTo="debugger" />
    <logger name="*" minlevel="Info" writeTo="console" />
 </rules>
</nlog>

1 个答案:

答案 0 :(得分:0)

在Test Explorer窗口中,选择您的测试并单击Output链接:

enter image description here

它将打开一个包含控制台内容的新窗口

enter image description here