C# System.Net 跟踪日志 - 只跟踪一种方法而忽略其他方法?
我正在使用 System.Net 跟踪,如下所述:
http://ferozedaud .blogspot.com/2009/08/tracing-with-systemnet.html
但这会跟踪使用 HttpWebRequest 发出的每个请求。跟踪文件很大。我只想跟踪当我调用某个 URI 时发生的情况,例如:
https://api.example.com/oauth/RequestToken
因为在我的 Web 应用程序运行几个小时后连接到此 URI 出现问题。
我想忽略对其他 URI 的所有请求,例如:
https://api.example.com/Foo
因为这些请求工作正常,并且用我不需要的数据填充日志。
I'm using System.Net tracing as described here:
http://ferozedaud.blogspot.com/2009/08/tracing-with-systemnet.html
But that traces every request made with HttpWebRequest. The trace file is huge. I only want to trace what happens when I am calling a certain URI eg:
https://api.example.com/oauth/RequestToken
Because connecting to this URI has problems after my web app has been running for several hours.
I want to ignore all requests to other URIs eg:
https://api.example.com/Foo
Because these requests are working fine, and are filling up the log with data that I do not need.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要查看邮件过滤器(向下滚动大约一半) -沿着页面向下到达名为“消息过滤器”的部分。)另一页此处专门用于消息日志记录过滤器。以下是对您的示例的配置应该是什么样子的有根据的猜测:
还有跟踪日志过滤器的自定义实现 此处 这可能会有所帮助。
You might want to take a look at Message Filters (scroll down about half-way down the page to the section called "Message Filters".) Another page here dedicated solely to message logging filters. Here's an educated guess at what the configuration should look like for your example:
There is also a custom implementation of a trace log filter here that might be helpful.