Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where's result of System.Diagnostics.Trace.WriteLine?

Tags:

.net

In my code, I wrote some trace messages by using System.Diagnostics.Trace.WriteLine, but where could I get the messages? I have looked at Event Viewer but didn't find them.

like image 288
Carlos Liu Avatar asked May 09 '11 01:05

Carlos Liu


People also ask

Where can I see system diagnostics debug WriteLine?

Diagnostics. Debug. WriteLine will display in the output window ( Ctrl + Alt + O ), you can also add a TraceListener to the Debug.

What is System diagnostics trace?

Tracing helps you isolate problems and fix them without disturbing a running system. This class provides methods to display an Assert dialog box, and to emit an assertion that will always Fail. This class provides write methods in the following variations: Write.

What is System Diagnostics C#?

Diagnostics provides a set of attributes and classes to interact with the system process, event managers, performance counts, etc. This namespace can help us too in debugging jobs. Let's review the useful actions inside System. Diagnostics namespace.

How do I trace debugging?

You can enable debugging or tracing by adding a #define DEBUG or #define TRACE line to the top of your code or using the /d:DEBUG or /d:TRACE compiler switch when you compile. See the example in Listing 21.7.


2 Answers

Are you debugging? Look at the "Output" Tab (View | Output, or Ctrl+Alt+O) in Visual Studio.

If it's not outputting there, you need to add a listener.

Check this documentation.

like image 91
ariel Avatar answered Sep 22 '22 21:09

ariel


Virtually, the key feature of Trace is that the trace messages are independent from the IDE basically. Because trace messages are also available in the release build, you can also get them, when the software was already shipped and/or you have no IDE in avail. You guessed right, there is a tool, which makes you see those messages apart from VS. If you are not debugging (i.e. no debug-console allocated in VS), you can see the trace messages with the tool Debugview running in parallel instead of Windows' EventViewer. It is also possible to write trace messages to a file by editing/creating a *.config file accompanying the assembly in question, which also records the history of messages.

like image 21
Nico Avatar answered Sep 21 '22 21:09

Nico