Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where will Debug.WriteLine in C# output to when build release?

Tags:

I put a lot of Debug.WriteLine in my code for debug purposes. When I am ready to build for release, will these Debug.Write influence the release build, and where do they output to?

like image 488
toosensitive Avatar asked Jun 07 '12 17:06

toosensitive


People also ask

What happens if DEBUG WriteLine does not include debug symbol?

So if your release configuration does not include DEBUG symbol the Debug.WriteLine calls will be omitted during compilation and there will be no output. Show activity on this post. If you switch them to Trace.WriteLine you can define arbitrary listeners in the app/web.config file. Show activity on this post.

How to use the WriteLine method in Visual Studio?

And: The WriteLine method writes a text line to the "Output" console in Visual Studio. Output: In Visual Studio, you have an "Output" window. Go to View -> Output, and then you will see Output appear.

What is the default output type for debug write line?

The exception to this is the String object. Explicit overloads take precedence, so an arg value of a single string will default to the Debug.WriteLine (String, String) overload. By default, the output is written to an instance of DefaultTraceListener.

Where can I see the output of my program in debug?

If you’re running your program in the Visual Studio debugger, and you’ve built it in debug mode (the DEBUG build flag is set), you’ll see the output from System.Diagnostics.Debug.WriteLine (and related debug output functions) in the Output window in Visual Studio (typically configured as a tabbed area at the bottom of the Visual Studio window.


2 Answers

Debug.WriteLine is annotated with the Conditional attribute. (see MSDN)

The ConditionalAttribute tells the compiler not to generate that code unless the DEBUG flag is supplied.

like image 179
Jim Schubert Avatar answered Nov 15 '22 09:11

Jim Schubert


From MSDN: "The ConditionalAttribute attribute is applied to the methods of Debug. Compilers that support ConditionalAttribute ignore calls to these methods unless "DEBUG" is defined as a conditional compilation symbol. Refer to a compiler's documentation to determine whether ConditionalAttribute is supported and the syntax for defining a conditional compilation symbol."

So if your release configuration does not include DEBUG symbol the Debug.WriteLine calls will be omitted during compilation and there will be no output.

like image 38
dodsky Avatar answered Nov 15 '22 10:11

dodsky