Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Console.writeline() /trace.writeline()

Tags:

trace

console

What is the difference between Console.WriteLine() and Trace.WriteLine() ?

like image 289
A.Sri Avatar asked Mar 02 '17 06:03

A.Sri


People also ask

What is the difference between console WriteLine and debug WriteLine?

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.

What is trace WriteLine?

WriteLine(String) Writes a message to the trace listeners in the Listeners collection. WriteLine(Object, String) Writes a category name and the value of the object's ToString() method to the trace listeners in the Listeners collection.

What is console WriteLine ()?

WriteLine(Object) Writes the text representation of the specified object, followed by the current line terminator, to the standard output stream. WriteLine(String, Object, Object, Object, Object)

Is console WriteLine a function?

Write. Line() is a function: Writes the current line terminator to the standard output stream. Console. WriteLine() is a method: Writes data, followed by the current line terminator, to the standard output stream.


1 Answers

Look at these from the "Debugging" perspective.

  • We started debugging using Console.WriteLine()
  • Later we got to know it might not be good to print debugging data on console always. We might not even have a console. Then we started using Debug.WriteLine(), which prints my debug information on Visual Studio output window.
  • Then we got to 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().
  • Here's a very good reference: Usage of Trace and Debug

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."

Here are some relevant items that you might find useful:

  • Where to look for trace logs ?
  • How to set Debug or Release Configurations ?
  • Understanding build configurations.
like image 79
Vikas Kaushik Avatar answered Sep 21 '22 07:09

Vikas Kaushik