如何没有任何异常打印当前的堆栈跟踪。NET中? [英] How to print the current Stack Trace in .NET without any exception?
问题描述
我有一个常规的C#code。 我没有例外的。我想以编程方式记录当前堆栈跟踪调试的目的。例如:
公共无效executeMethod()
{
logStackTrace();
方法();
}
有一个看<一href="https://msdn.microsoft.com/en-us/library/vstudio/system.diagnostics%28v=vs.110%29.aspx"><$c$c>System.Diagnostics$c$c>命名空间。很多好吃的东西在那里!
System.Diagnostics.StackTrace T =新System.Diagnostics.StackTrace();
这是真的好有一捅围绕学习什么引擎盖下怎么回事。
我建议你看看到日志记录解决方案(如NLOG,log4net的或Microsoft模式和实践企业库),它可以达到你的目的,然后一些。祝你好运队友!
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();
}
Have a look at the 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 whats 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. Good luck mate!
这篇关于如何没有任何异常打印当前的堆栈跟踪。NET中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!