'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组件的一个示例网页,这个网页可以从ASP Installable Components主菜单运行。 确保在Internet Services Manager中不允许匿名访问包含示例文件的目录或loggingutility.asp文件,否则将不能访问日志文件。打开loggingutility.asp文件或包含该文件的目录的Properties对话框的Directory Security选项卡,点击 Anonymous access and authentication control部分的Edit按钮,打开Authentication Method对话框,并关闭 Anonymous access选项。 必须改变日志文件的文件名以适合你的计算机。在缺省Web网站的Properties对话框的Web Site选项卡中,打开W3C Extended Logging,如图6-22所示: