Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

asp.net

nlog

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?

like image 240
Pure.Krome Avatar asked Oct 31 '08 02:10

Pure.Krome


People also ask

How do I get the Output in Output window in Visual Studio code?

To open the Output window, on the menu bar, choose View > Output, or press Ctrl+Alt+O.

How do I get the Output window in Visual Studio?

The Output window shows the output of the compiler/build system as well as output from debugging sessions. To make the Output window visible, choose View > Output or press [Alt+2] (not Alt+F2!)

How do I view logs in Visual Studio?

To examine the activity logRun Visual Studio with the /Log command line switch to write ActivityLog. xml to disk during your session. After closing Visual Studio, find the activity log in the subfolder for Visual Studio data: %AppData%\Microsoft\VisualStudio\<version>\ActivityLog.


1 Answers

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

like image 186
Scott P Avatar answered Oct 09 '22 04:10

Scott P