[英]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.