简体   繁体   English

跟踪ASP.NET应用程序中的所有方法调用

[英]Trace all method calls in ASP.NET application

I need to trace all method calls in an ASP.NET application for a period of time, say 24 hours, into a log file. 我需要跟踪ASP.NET应用程序中的所有方法调用一段时间,比如24小时,进入日志文件。 Looking for tools that allows me to do this? 寻找允许我这样做的工具? I'm interested in in getting something like this out: 我有兴趣得到这样的东西:

2009-10-12T13:00:41 MyClass.MyMethod("arg1.toString()", "arg2.toString()") 
... other nested calls inside this method ...
2009-10-12T13:00:42 MyClass.MyMethod() 0.2312 seconds

Basically a way to see how long each method call took and what input it got. 基本上是一种方法来查看每个方法调用花了多长时间以及它获得了什么输入。

You might want to look at ANTS Profiler . 你可能想看看ANTS Profiler It can give you line by line execution time and has an option to do .NET framework code as well as your own. 它可以为您提供逐行执行时间,并且可以选择执行.NET框架代码以及您自己的代码。

You should have a look at PostSharp , which can provide that kind of functionality 你应该看看PostSharp ,它可以提供这种功能

From the samples on the home page: 从主页上的示例:

public class TraceAttribute : OnMethodBoundaryAspect 
{ 
  public override void OnEntry( MethodExecutionEventArgs eventArgs) 
  { Trace.TraceInformation("Entering {0}.", eventArgs.Method);  } 

  public override void OnExit( MethodExecutionEventArgs eventArgs) 
  { Trace.TraceInformation("Leaving {0}.", eventArgs.Method);   } 
}

Then apply this trace attribute to the methods you want to trace : 然后将此trace属性应用于要跟踪的方法:

[Trace]
public void MyMethod(int myArg)
{
}

I think you can also use ELMAH (which is probably more flexible), but I never used it myself... 我想你也可以使用ELMAH (这可能更灵活),但我自己从未使用它......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 来自Asp.Net Web Api异步/任务调用的正确堆栈跟踪 - Proper Stack Trace from Asp.Net Web Api Async/Task calls 如何在使用ASP.NET构建的Web服务中安排方法调用 - How to schedule method calls in a webservice built with ASP.NET 如何计算对ASP.NET Web API POST方法的调用 - How to count calls to ASP.NET Web API POST method 在 ASP.NET web 应用程序中,我在哪种方法中实现一个每 5 分钟调用一次 function 的计时器? 没有 main() 可以在 PageLoad 中吗? - In ASP.NET web application, in which method do I implement a timer that calls a function every 5 minutes? There's no main() could it be in PageLoad? 如何在ASP.NET中禁用跟踪信息? - How to disable Trace Information in ASP.NET? 如何在asp.net web应用程序中调用javascript方法 - How to call javascript method in asp.net web application 更改现有Asp.Net MVC 5(身份2)应用程序的种子方法? - Change seed method for an existing Asp.Net MVC 5 (Identity 2) application? ASP.NET Core 应用程序的 Configure 方法中是否有强制的语句顺序? - Is there a mandatory order of statements in the Configure method of a ASP.NET Core application? 在 ASP.Net web 应用程序数据层中实现 Static 方法是否安全? - Is it safe to implement Static method in ASP.Net web application Datalayer? Asp.net核心应用程序中无法正常工作的索引方法 - Not working index method in Asp.net core application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM