如何使用C#在WPF中记录HTTPRequest和HTTPResponse [英] How to log HTTPRequest and HTTPResponse in WPF using C#

查看:733
本文介绍了如何使用C#在WPF中记录HTTPRequest和HTTPResponse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在WPF项目中新工作,用C#语言编写。此应用程序为工作站上的其他应用程序提供浏览器,电子邮件,打印,日志记录等操作基础。



现在,特定应用程序想要跟踪HTTPRequests和HTTPResponses并且想要我们将它们记录到日志文件中。



有人能建议做什么以及怎么做?

Hi,

I am newly working in WPF project, written in C# language. This application provides the operating base like browser, email, printing, logging etc to other applications on workstations.

Now a particular application wants to trace the HTTPRequests and HTTPResponses and want us to log them into log files.

Can anyone suggest what and how to do that?

推荐答案

如果你记录什么并不重要,是不是WPF。一种可能是使用类 System.Diagnostics.EventLog

https://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog%28v=vs.110%29 .aspx [ ^ ]。



您可以使用的一种流行的开源第三方产品是Apache Log4net:

http://en.wikipedia.org/wiki/Log4j#Ports [ ^ ],

http://logging.apache.org/log4net [ ^ ],

https://github.com/apache/log4net [ ^ ]。



点数您可以获取HTTP请求/响应数据的代码取决于您正在做什么。



-SA
If does not matter what you log and is it WPF or not. One possibility is using the class System.Diagnostics.EventLog:
https://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog%28v=vs.110%29.aspx[^].

One popular open-source 3rd-party product you can use is Apache Log4net:
http://en.wikipedia.org/wiki/Log4j#Ports[^],
http://logging.apache.org/log4net[^],
https://github.com/apache/log4net[^].

The points of code where you can grab HTTP request/response data depends on what you are doing.

—SA


这篇关于如何使用C#在WPF中记录HTTPRequest和HTTPResponse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆