tags:

views:

458

answers:

2

Hi folks, I'm using NLog to log my stuff. I'm trying to send the output to the console (or colouredconsole) ... which i'm hoping would goto the visual studio 'OUTPUT' window for any ASP.NET web site/app/mvc app.

It's not.

If i change the target to 'file' then it works for sure.

So - can NLog output to the 'output' window for web apps?

PS. Please do not post suggesting to use other progs, like log4net, etc.

cheers!

A: 

I use this class for output to VS debugger output window:
http://www.u2u.info/Blogs/Kris/Lists/Posts/Post.aspx?ID=11
but don't know if it will work with nlog (it will if it uses TextWriter for output), you can give it a try!

Hrvoje
+5  A: 

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"&gt;

  <targets>
        <target name="debugger" xsi:type="Debugger" layout="${logger}::${message}"/>
  </targets>

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

-Scott

Scott P
AWESOMESAUCE! i never knew there was a type == Debugger.WINNAH!
Pure.Krome
Just what I was looking for, thanks!
tpower