如何在 .NET 中记录应用程序的整个堆栈跟踪
我刚刚开始开发现有的 .NET 应用程序,其中包含大约 40 个活动项目。 在熟悉该项目的同时,我发现自己不断地逐步浏览该应用程序只是为了了解结构和逻辑流程。 如果我可以让应用程序运行并记录每个方法调用并在事后查看日志,那么这个过程就会变得更加容易。 我知道我可以添加 Debug.WriteLine 或 Trace.WriteLine 语句,但将这些语句添加到 40 个项目中的大多数方法听起来有点过头了。 这种方法有什么好的替代方法吗?
CLR Profiler 向我介绍了适当的关键字“调用图”,这导致我提出了一个重复的问题, 如何查看 .NET 程序动态调用图的可视化?。
I've just started work on an existing .NET application with about 40 active projects. While familiarizing myself with the project, I find myself constantly stepping through the application just to learn the structure and logic flow. It would make this process so much easier if I could let the application run and log every method call and review the log afterwards. I know I can add Debug.WriteLine
or Trace.WriteLine
statements, but adding those statements to most methods in 40 projects sounds like overkill. Are there any good alternatives to this approach?
CLR Profiler introduced me to the appropriate keyword 'call graph' which led me to a duplicate question, How can I see a visualization of a dynamic call graph for a .NET program?.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
CLR Profiler 可以为您提供所需的堆栈跟踪。
The CLR Profiler can give you the stack traces you are looking for.
您可以查看 RedGate ANTS。 ANTS 的目的是性能分析,但分析器确实可以为您提供所分析的应用程序正在执行的操作的非常详细的视图,让您可以对调用堆栈进行切片和切块,还可以让您跳转到 Visual Studio。 虽然有点花钱,但是很值得。
You might check out RedGate ANTS. The purpose of ANTS is performance profiling, but the profiler does give you a very detailed view of what the profiled application is doing, lets you slice and dice the callstack and also lets you jump over to Visual Studio. It's a bit spendy, but well worth it.
或者您可以使用 PostSharp 之类的内容自动为所有方法添加日志记录。
Or you can use something like PostSharp to add the logging automatically for all the methods.