'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) 本書提供了演示使用Logging Utility組件的一個(gè)示例網(wǎng)頁,這個(gè)網(wǎng)頁可以從ASP Installable Components主菜單運(yùn)行。 確保在Internet Services Manager中不允許匿名訪問包含示例文件的目錄或loggingutility.asp文件,否則將不能訪問日志文件。打開loggingutility.asp文件或包含該文件的目錄的Properties對(duì)話框的Directory Security選項(xiàng)卡,點(diǎn)擊 Anonymous access and authentication control部分的Edit按鈕,打開Authentication Method對(duì)話框,并關(guān)閉 Anonymous access選項(xiàng)。 必須改變?nèi)罩疚募奈募赃m合你的計(jì)算機(jī)。在缺省Web網(wǎng)站的Properties對(duì)話框的Web Site選項(xiàng)卡中,打開W3C Extended Logging,如圖6-22所示: