Tutorials to .com

Tutorials to .com » Asp » Base » Advanced Programming ASP 3.0 (28)

Advanced Programming ASP 3.0 (28)

Print View , by: iSee ,Total views: 19 ,Word Count: 2052 ,Date: Sat, 25 Apr 2009 Time: 7:48 PM

6.2.11 Logging Utility Component
Logging Utility component is the new asp 3.0 components, provides a way to access the log file, the log file is supported by the server for Web and FTP site created by IIS.
1. Members of the Logging Utility Component
Logging Utility component provides six methods to read the contents of the log file to a new record has been written into the log file exists. These methods and the previous chapter discussed the methods of FileSystemObject object similarity, such as shown in Table 6-9:
Table 6-9 Logging Utility Component and Description
Methods
Description

AtEndOfLog ()
Traversal record ReadLogRecord method used, if all records in the document have been read out, the return value is True

CloseLogFiles (io_mode)
Close to open the log file, io_mode to turn off the value of the specified documents, constant ForReading (1) that the closure is opened for all the documents read out, ForWriting (2) that the closure of all open files for writing, AllOpenFiles (32) that the closure of open all documents

OpenLogFile (filename, io_mode,
service_name, service_instance,
output_format)
Open the log file specified by filename or log file set io_mode optional parameters can be set to ForReading (default value 1) or ForWriting (2). When read from a specific IIS services (such as the "W3SVC" and "1"), the optional parameter service_name and restrictions service_instance return from the paper records. Output_format optional parameter to specify the use of written documentation of the format

ReadFilter (start, end)
When the specified time and date range to read documents, restrictions on the return of the record, the two parameters are optional, if neglected, then, start is the first record of a document, end is the last record

ReadLogRecord ()
OpenLogFile method used to open from the current log file to read the next record

WriteLogRecord (logging_object)
Open for read out from the paper to write a record open for written documents, logging_object parameter is a reference source to preserve records of the Logging Utility component object instance variables

Logging Utility provides 20 kinds of components with the corresponding IIS logging properties, such as shown in Table 6-10:
Table 6-10 Logging Utility and describe the properties of components
Properties
Description

BytesReceived
Browser requests received from the number of bytes

BytesSent
Response sent to your browser's bytes

ClientIP
The client or the host (that is, a proxy server) the IP address

Cookie
In the request to send the contents of the cookie

CustumFields
Add to request a custom header array

DataTime
Request the date and time (GMT)

Method
Operation types, such as "Get" and "Post"

ProtocolStatus
Returned to the client status message, that is "200 OK"

ProtocolVersion
Protocol version string, such as "HTTP/1.1"

Referer
Link initialization request includes the URL of the page

ServerIP
IIS machines IP Address

ServerName
IIS server machine name

ServerPort
Request to reach the port number, such as "80"

ServiceName
Server name, such as "MSFTPSVC" or "W3SVC"

TimeTaken
Retrieval and the creation of the total processing time of the page

URIQuery
Request URL query string added to all parameters

URIStem
Instructions of the target URL

UserAgent
Sent by the client user agent string

UserName
If access to the server is not anonymous, UserName is the user's login name

Win32Status
To deal with the request to return to the Win32 status code

2. Logging Utility component used
Logging Utility component of the application of the most common log file for custom inquiries. Select from the existing document a number of records the ability to write new documents, means that certain types of entry summary, or selectively record to single out some future use.
In order to use the ForReading, ForWriting and AllOpenFiles constant, must be part of a web page that contains the METADATA Directive <HEAD>.
<! - METADATA TYPE = "typelib" FILE = "C: \ WinNT \ system32 \ inetsrv \ logscrpt.dll" ->
In order to traverse records, only to open the file and repeat the call ReadLogRecord, until the return value of AtEndOfLog to True. In the example below will filter records, only the last record within 24 hours.
'Create the component instance
Set objLogUtil = Server.CreateObject ( "MSWC.IISLog")

'open the log file for reading, for the W3SVC instance number 1
objLogUtil.OpenLogFile "extend #. log", ForReading, "W3SVC", 1, 0

'set a filter for the last day's records only
objLogUtil.ReadFilter DateAdd ( "d", -1, Now), Now

'loop through the records
Do While Not objLogUtil.AtEndOfLog
objLogUtil.ReadLogRecord 'read the next record
Response.Write "Request received for page" & objLogUtil.URLStem & "on" _
& ObjLogUtil.DateTime & "from IP address" _
& ObjLogUtil.ClientIP & ". <BR>"
Loop
objLogUtil.CloseLogFiles (ForReading) 'close the file (s)
This book provides a demonstration of the use of the Logging Utility component of a sample page, the page from the ASP Installable Components to run the main menu.
Internet Services Manager to ensure that does not allow anonymous access in the sample file that contains the directory or file loggingutility.asp Otherwise, they would not be able to access the log file. Loggingutility.asp open files or directories that contain the file's Properties dialog box of the Directory Security tab, click Anonymous access and authentication control part of the Edit button to open the Authentication Method dialog box, and close the Anonymous access option.
Must change the file name of log file to fit your computer. In the Default Web Site Properties dialog box of the Web Site tab, open the W3C Extended Logging, as shown in Figure 6-22:

Figure 6-22 Use of the Logging Utility component set 1
In this dialog box, click the Properties button, open the Extended Logging Properties dialog box will open here to use the file name. Select fixed-size log file options, such document is extend1.log and extend2.log players and so on. As shown in Figure 6-23:

Figure 6-23 Use of the Logging Utility component set 2
Open the Extended Properties tab, make sure the entries you want, as shown in Figure 6-24:

Figure 6-24 Use of the Logging Utility component set 3
Can now run the sample page and check the results, you can use the following code in the HTML table display values.
<%
Set objLogUtil = Server.CreateObject ( "MSWC.IISLog")
objLogUtil.OpenLogFile "extend #. log", ForReading, "W3SVC", 1, 0
objLogUtil.ReadFilter DateAdd ( "d", -1, Now), Now
%>
<TABLE CELLPADDING="10">
<TR>
<TH> Date / Time </ TH>
<TH> Client IP </ TH>
<TH> Bytes Sent </ TH>
<TH> Target URL </ TH>
</ TR>
<%
Do While Not objLogUtil.AtEndOfLog
objLogUtil.ReadLogRecord 'read the next record
%>
<TR>
<TD> <% = ObjLogUtil.DateTime%> </ TD>
<TD> <% = ObjLogUtil.ClientIP%> </ TD>
<TD> <% = ObjLogUtil.BytesSent%> </ TD>
<TD> <% = ObjLogUtil.URLStem%> </ TD>
</ TR>
<%
Loop
objLogUtil.CloseLogFiles (ForReading)
%>
As a result, as shown in Figure 6-25:

Figure 6-25 using the Logging Utility component of the sample results

6.3 third-party server components
In this section, a brief overview of the ASP system to use some common commercial and free third-party server components.
The development of Web sites, it is important to complete the two tasks is to manage compatibility, as well as upload files to the server. Here are the two components can contribute to the completion of the above-mentioned tasks, but also to introduce another component can be used to replace Microsoft's Registry Access component (the component is generally from the Web site received).
In Appendix G, are given some of the most useful list of components.

6.3.1 BrowserHawk components
Many people like to use by the IIS and asp component Browser Capability provided, it will encounter a problem, the definition of a document browser (browscap.ini) require periodic maintenance or replacement in order to keep pace with the requirements of the new browser.
Broscap.ini provided Cyscape upgrade version, while providing their own in the server-side and client-side browser detection to the Components. In addition, it provides a convenient graphical interface for viewing and modifying your browser definition files, as shown in Figure 6-26:

Figure 6-26 BrowserHawk components
Can see that for each browser type, there are many attributes, such as dynamic HTML, style sheets, javascript version of the file upload ability, SSL (Secure Sockets Layer) support, operating system details as well as language. Microsoft's Browser Capability with the same components can also add your own content. There is also a very useful guide with the characteristics of style, can help us to a new browser is added to the definition of the type of document, as shown in Figure 6-27:

Figure 6-27 Add a new definition file to the browser's Wizard
BrowserHawk have identified a new component browser (using a special pattern-matching algorithm) as well as those who support a series of default browser, including Opera and WebTV. The use of filtering to add a new property is also very easy.
Of course, BrowserHawk components may be the greatest advantage of a regular basis from the company's Web site Cyscape browser definition files to automatically detect the new version, at the same time to absorb some of the elements into the current document using the definition, which means that there is no need to constantly definition files to copy to all of the Web server.
BrowserHawk components easier to use, and Browser Capability components are compatible, need to do is create a component instance in the Server.CreateObject method or change <OBJECT> elements ProgID. The "MSWC.BrowserType" changed to "cyScape.browserObj".
Set objBCap = Server.CreateObject ( "cyScape.browserObj")
Of potential problems BrowserHawk components should read the document. Cyscape companies from the Web site (http://www.cyscape.com) to download copies of BrowserHawk. This chapter has already included the use of the sample components BrowserHawk page so that readers can understand how to use BrowserHawk components, Chapter06 directory in a subdirectory BrowserHawk can find the sample page.


Asp Base Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.