Private iWin32StatusCode As Integer = Nothing ' (sc-win32-status)
Private iBytesSentByServer As Long = 0 ' (sc-bytes)
Private iBytesReceivedByServer As Long = 0 ' (cs-bytes)
Private iProcessingTime As Long = 0 ' (time-taken)
Private sRequestProtocol As String = "" ' (cs-version)
Private sHostHeader As String = "" ' (cs-host)
Private sUserAgent As String = "" ' (cs(User-Agent))
Private sCookie As String = "" ' (cs(Cookie))
Private sReferer As String = "" ' (cs(Referer))
' Additional Useful Fields
Private sServerSoftware As String = ""
Private sW3CExtendedLogFormatVersion As String = ""
Private dStartProcessDateTime As DateTime
Private dEndProcessDateTime As DateTime
Private sBrowserMinorVersion As String = ""
Private sRequestContentType As String = ""
Private sResponseContentType As String = ""
Private sCrawler As String = ""
' dsn is in machine.config files
Private dsn As String = CType(ConfigurationSettings.AppSettings("WebLoggerDSN"), String)
Private conn As SqlConnection
Private cmd As SqlCommand
Public Sub Init(ByVal app As HttpApplication) Implements IHttpModule.Init
AddHandler app.BeginRequest, AddressOf BeginRequest
AddHandler app.EndRequest, AddressOf EndRequest
AddHandler app.Error, AddressOf OnError
End Sub
Public Sub Dispose() Implements IHttpModule.Dispose
' add clean-up code here if required
dsn =
Nothing
cmd =
Nothing
conn.Close()
conn =
Nothing
End Sub
Public Sub BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
dStartProcessDateTime = DateTime.Now
' Get access to the request context
Dim context As HttpApplication
context =
CType(sender, HttpApplication)
' Create stream watcher so we can get bytes downloaded
Dim app As HttpApplication = DirectCast(sender, HttpApplication)
streamWatcher =
New WebLogger.TransparentStream(app.Response.Filter)
app.Response.Filter = streamWatcher
.sStartRequestDate = dStartProcessDateTime.ToString("yyyy-MM-dd")
' Time (time) - The time that the activity occurred.
sStartRequestTime = dStartProcessDateTime.ToString("HH:mm:ss")
' Client IP (c-ip) - The IP address of the client that accessed your server.
sClientIP = context.Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If sClientIP = "" Or sClientIP = Nothing Then
sClientIP = context.Request.ServerVariables("REMOTE_ADDR")
End If
' User Name (cs-username) - The name of the authenticated user who accessed your server.
' This does not include anonymous users, who are represented by a hyphen (-).
sAuthUserName = context.Request.ServerVariables("AUTH_USER")
' Service Name (s-sitename) - The Internet service and instance number that was accessed by a client.
sServiceName = context.Request.ServerVariables("INSTANCE_META_PATH")
' Server Name (s-computername) - The name of the server on which the log entry was generated.
'sServerName = context.Request.ServerVariables("SERVER_NAME")
Try
sServerName = Dns.GetHostName()
Catch
sServerName =
Nothing
End Try
' Server IP Address (s-ip) - The IP address of the server on which the log entry was generated.
sServerIP = context.Request.ServerVariables("LOCAL_ADDR")
' Server Port (s-port) - The port number the client is connected to.
iServerPort = context.Request.ServerVariables("SERVER_PORT")
' Method (cs-method) - The action the client was trying to perform (for example, a GET method).
sHTTPMethod = context.Request.ServerVariables("REQUEST_METHOD")
' URI Stem (cs-uri-stem) - The resource accessed; for example, Default.htm.
sURLVisited = context.Request.ServerVariables("URL")
' URI Query (cs-uri-query) - The query, if any, the client was trying to perform.
sQueryString = context.Request.ServerVariables("QUERY_STRING")
' Protocol Status (sc-status) - The status of the action, in HTTP or FTP terms.
iProtocolStatusCode = context.Response.StatusCode
' Win32® Status (sc-win32-status) - The status of the action, in terms used by Microsoft Windows®.
iWin32StatusCode =
Nothing
' Bytes Sent (sc-bytes) - The number of bytes sent by the server.
' [This value is retrieved in EndRequest]
iBytesSentByServer = 0
' Bytes Received (cs-bytes) - The number of bytes received by the server.
iBytesReceivedByServer = context.Request.ServerVariables("CONTENT_LENGTH")
' Time Taken (time-taken) - The duration of time, in milliseconds, that the action consumed.
' [This value is retrieved in EndRequest]
iProcessingTime = 0
' Protocol Version (cs-version) - The protocol (HTTP, FTP) version used by the client. For
' HTTP this will be either HTTP 1.0 or HTTP 1.1.
sRequestProtocol = context.Request.ServerVariables("SERVER_PROTOCOL")
' Host (cs-host) - Displays the content of the host header.
sHostHeader = context.Request.Headers("Host")
' User Agent (cs(User-Agent)) - The browser used on the client.
sUserAgent = context.Request.ServerVariables("HTTP_USER_AGENT")
' Cookie (cs(Cookie)) - The content of the cookie sent or received, if any.
sCookie = context.Request.Headers("Cookie")
' Referrer (cs(Referer)) - The previous site visited by the user. This site provided a link to
' the current site.
sReferer = context.Request.ServerVariables("HTTP_REFERER")
Go through this link its will help u know more details:
http://forums.asp.net/t/1057552.aspx