How can I output NLog messages to Visual Studio's Output Window?

asp.netNlog

asp.net Problem Overview


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.

Can NLog output to the Output window for web apps?

asp.net Solutions


Solution 1 - asp.net

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>

-Scott

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPure.KromeView Question on Stackoverflow
Solution 1 - asp.netScott PView Answer on Stackoverflow