Just as you mentioned,
Console.WriteLine writes to the standard output stream, either in
debug or release. Debug.WriteLine writes to the trace listeners in the
Listeners collection, but only when running in debug. When the
application is compiled in the release configuration, the Debug
elements will not be compiled into the code.
In short, if you want to show a message to your user in a console application, you could use Console.WriteLine
,if your purpose is solely for debugging, it is recommended that you use Debug.WriteLine
.
But we know that we shouldn't print all debug information in release mode, so we should use Trace.WriteLine()
in release mode. In debug mode we can see outputs from both Debug.WriteLine()
and Trace.WriteLine()
.
For more details, you can check this document: How to trace and debug in Visual C#
From this document,we will find:
You can use the Trace and the Debug classes separately or together in
the same application. In a Debug Solution Configuration project, both
Trace and Debug output are active. The project generates output from
both of these classes to all Listener objects. However, a Release
Solution Configuration project only generates output from a Trace
class. The Release Solution Configuration project ignores any Debug
class method invocations."
The following link should be helpful for you.
Trace logs location, where to view them
https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-set-debug-and-release-configurations?view=vs-2015&redirectedfrom=MSDN