Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C#模块中获取IIS日志数据_C#_Asp.net_Iis - Fatal编程技术网

在C#模块中获取IIS日志数据

在C#模块中获取IIS日志数据,c#,asp.net,iis,C#,Asp.net,Iis,我正在为IIS编写.Net模块,以在IIS写入日志文件之前或之后获取日志详细信息。根据MSDN文档 HttpApplication.LogRequest Event Occurs just before ASP.NET performs any logging for the current in LogRequest handler request. 那么,如何获取如下所示的日志数据: #Software: Microsoft Internet Information Services 8.

我正在为IIS编写
.Net模块
,以在IIS写入日志文件之前或之后获取日志详细信息。根据
MSDN文档

HttpApplication.LogRequest Event Occurs just before ASP.NET performs any logging for the current in LogRequest handler request.
那么,如何获取如下所示的日志数据:

#Software: Microsoft Internet Information Services 8.0

#Version: 1.0

#Date: 2014-11-27 10:42:57

#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus  sc-win32-status time-taken

2014-11-27 10:42:57 ::1 GET / - 29897 - ::1 Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/537.36+KHTML,+like+Gecko)+Chrome/39.0.2171.71+Safari/537.36- 200 0 0 42905

不,我无法在HttpModule中获取IIS日志数据。我需要编写自定义HttpModule并使日志数据与IIS日志数据相同。但我无法在自定义HttpModule中获取以下字段:耗时、字节发送、接收和win32状态代码

您想访问日志文本文件流,还是只想访问日志文件中包含的相同数据?我不想访问日志文件,只想获取IIS在.Net模块中写入日志文件的相同数据日志条目中的信息来自
HttpContext
对象,因此在您的情况下,只需设置一个断点并分析您可以从该对象中挖掘出什么。可以在
HttpContext
中找到日志条目中的是信息,但我不知道用户配置要记录的详细信息,因此在不知道要记录的详细信息的情况下,我需要获取日志数据。因此,我应该在
HttpModule
中获取日志详细信息。是否可以在当前上下文中读取IIS日志数据?