如何将 NLog 消息输出到 Visual Studio 的输出窗口? [英] How can I output NLog messages to Visual Studio's Output Window?

查看:55
本文介绍了如何将 NLog 消息输出到 Visual Studio 的输出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将输出发送到控制台(或 colouredconsole)...我希望(也?)转到 Visual Studio 的 Output 窗口以获取任何 ASP.NET网站/应用程序/mvc 应用程序.

I'm trying to send the output to the console (or colouredconsole) ... which I'm hoping would (also?) go to the Visual Studio's Output window for any ASP.NET web site/app/mvc app.

默认情况下不是,但如果我将目标更改为文件",那么它肯定可以工作.

It doesn't by default, but if I change the target to 'file' then it works for sure.

NLog 可以输出到网络应用程序的 Output 窗口吗?

Can NLog output to the Output window for web apps?

推荐答案

可以使用这个配置文件(app路径中的nlog.config):

You can use this configuration file (nlog.config in the app path):

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

-斯科特

这篇关于如何将 NLog 消息输出到 Visual Studio 的输出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆