Can I write to the console log to debug a web application using C #

I want to write some variables in my ASP MVC3 application during debugging. I tried various things such as:

Debug.Log(topTitle + " " + subTitle); 

This does not work. How can I write to the VS2010 console from my C # code?

+6
source share
4 answers

To write to the console window in Visual Studio, use:

 System.Diagnostics.Debug.WriteLine(topTitle + " " + subTitle); 

Below is a screenshot:

enter image description here

+13
source

You can use the Debug class to extract debugging information from your application. You can even add a tracer to your web.config file to redirect the output to a file or event log when you are not debugging Visual Studio.

+1
source

To write to the console window in Visual Studio, use:

 System.Diagnostics.Debug.WriteLine(topTitle + " " + subTitle); 

or you can view and manage using the Immediate window . Direct window

0
source

System.Diagnostics.Debug does not have a logging method. You can use System.Diagnostics.Debug.WriteLine . You can view the output in the output window. Then make sure you are in debug mode.

. Debug information is displayed only when you are working in debug mode. In release mode, debug statements will not be visible (you can use Trace instead of Debug if you want these statements to be visible in Release mode).

Please refer to the following article

How to track and debug in Visual C #

0
source

Source: https://habr.com/ru/post/927991/


All Articles