Attaching a console to running an ASP.NET application

Suppose I have a library in which I added several Console.WriteLine(..) statements to help me during the implementation and see what happens when I use the library in a console application.

Now I want to use the same library in an ASP.NET application. Ideally, I could log into the production web server and somehow run the command line and attach it to the website and see the messages in real time as they appear. How to do it?

+6
source share
2 answers

I'm not sure if it works with ASP.Net, but you can use Trace.WriteLine instead of Console.WriteLine, and then use DebugView to view traces as they arise.

+1
source

You cannot - there is no such console as a console on the server. You need to use the Trace statements and attach the TraceListener .

You can try TextWriterTraceListener . initializeData is the path to where the log file will be written. Note. The user of the application pool identifier will need write permission for this path.

 <configuration> <system.diagnostics> <trace autoflush="false" indentsize="4"> <listeners> <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" /> <remove name="Default" /> </listeners> </trace> </system.diagnostics> </configuration> 
+2
source

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


All Articles