Asp.net

如何將 NLog 消息輸出到 Visual Studio 的輸出視窗?

  • October 31, 2008

我正在嘗試將輸出發送到控制台(或 colouredconsole)……我希望它(也是?)轉到Output任何 ASP.NET 網站/應用程序/mvc 應用程序的 Visual Studio 視窗。

預設情況下它不是,但如果我將目標更改為“文件”,那麼它肯定可以工作。

NLog 可以輸出到Outputweb 應用程序的視窗嗎?

您可以使用此配置文件(應用路徑中的 nlog.config):

<?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="debugger" xsi:type="Debugger" layout="${logger}::${message}"/>
 </targets>

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

-斯科特

引用自:https://stackoverflow.com/questions/252464