Let’s say I have a library, in which I added a few Console.WriteLine(..)
statements to help me out during the implementation and see what’s going on when I use the library in a Console App.
Now I want to use the same library in an ASP.NET app. Ideally I would be able to log on to the production webserver, and somehow start a command prompt and attach it to the website and see the messages in real time as they occur. How do I do that?
You can't - there is not such thing as a console on the server. You need to use Trace statements and attach a TraceListener.
You can try TextWriterTraceListener
. initializeData
is the path to where the log file will be written. Note: The App Pool Identity user will require write permission to 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>
I'm not sure it works with ASP.Net, but you can use Trace.WriteLine instead of Console.WriteLine and then use DebugView to view the traces as they happen.
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