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?
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With