debugcsharpCritical
How to print the current Stack Trace in .NET without any exception?
Viewed 0 times
nethowtraceanythecurrentexceptionprintstackwithout
Problem
I have a regular C# code. I have no exceptions. I want to programmatically log the current stack trace for debugging purpose. Example:
public void executeMethod()
{
logStackTrace();
method();
}Solution
Have a look at the
This is really good to have a poke around in to learn what's going on under the hood.
I'd recommend that you have a look into logging solutions (Such as NLog, log4net or the Microsoft patterns and practices Enterprise Library) which may achieve your purposes and then some.
System.Diagnostics namespace. Lots of goodies in there!System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace();This is really good to have a poke around in to learn what's going on under the hood.
I'd recommend that you have a look into logging solutions (Such as NLog, log4net or the Microsoft patterns and practices Enterprise Library) which may achieve your purposes and then some.
Code Snippets
System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace();Context
Stack Overflow Q#531695, score: 548
Revisions (0)
No revisions yet.