Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see console output from inside WCF service while debugging?

How might I see the SQL query generated from LINQ to SQL when debugging inside a WCF service? I thought I might just set dataContext.Log = Console.Out and the SQL would be written to the output/immediate window. It doesn't--is that because I am hosting using IIS? Console.WriteLine("Hello") doesn't even write anything to the output/immediate window.

How do see my console output?

like image 802
Patrick Szalapski Avatar asked May 25 '11 21:05

Patrick Szalapski


People also ask

How do I show console output?

IDE used is visual studio 2019. static void Main(string[] args) { int x; int y; Console. WriteLine("Enter the first value"); x = Convert.

How do I Debug a WCF service?

In Solution Explorer, right-click the WCF Client project and then click Set as Startup Project. Enable debugging in the app. config or web. config file.

How do I display the output window or console in Visual Studio?

Visual Studio Output Window usage and description. A developer also can display application runtime diagnostic messages to the output window using Debug or Trace class from . NET API. The output window can be open in two ways, first is from the menu bar, select View > Output, or using the shortcut key Ctrl+Alt+O.

How do I Debug IIS hosted WCF service?

The easiest way to debug a self-hosted WCF is to configure Visual Studio to launch both client and server when you choose Start Debugging on the Debug menu. If the WCF service is self-hosting inside or a process that cannot be launched in this manner, such as NT service, you cannot use this method.


2 Answers

You can try to use System.Diagnostics.Debug.WriteLine(), so when you distribute Release app these lines will be stripped out from code.

like image 59
Marco Avatar answered Sep 23 '22 07:09

Marco


You may want to write it to a file instead. dataContext.Log takes any TextWriter.

See this comment for a nice way to get a text writer writing to Debug.

like image 25
YetAnotherUser Avatar answered Sep 22 '22 07:09

YetAnotherUser