Mike knows the pain and frustration of having a web server crash unexpectedly... it happens when we least expect it. In this article, he's going to describe a simple way to create an ASP page that will allow us to view our web servers log files in a standard web page across the Internet.
View Your Web Servers Log Files With ASP - Windows 2000 and log files (Page 2 of 5 )
Whenever an error occurs either directly or in-directly through IIS, or whenever a file is retrieved from the web server, the details of that activity are stored in a log file. All IIS log files are stored in the c:\winnt\system32\w3svc1 directory. A new log file is created for each new day, and the names of these log files are sequential: ex010828.log, ex010829.log, etc. To get a better understanding of what an IIS web server log file looks like, fire up notepad and open any of the files in your web servers “c:\winnt\system32\w3svc1” directory. It should resemble the one shown below:
This is one of the log files sitting on the development server for devArticles.com. Our site is developed and tested using IIS and PHP on a Windows 200 server, and then deployed to our production server. Our production server runs Apache, PHP and MySQL on several Linux servers.
If you take a look at the log file, then you will notice it contains several rows of values. Each value is separated by a space and contains the details of that individual log entry. A log entry from the file shown above looks like this:
At the top of each Windows 2000 log file, there is a commented line (comments in a log file begin with “#”), which describes each of the fields in a log entry:
#Fields: date time c-ip cs-username s-ip s-port cs-method cs-uri-stem cs-uri-query sc-status cs(User-Agent)
So, in the sample log entry above, the first “field” is the date. The second is the time, third is the clients IP address, etc. Log files can contain just a couple of entries, or can contain thousands… it all depends on how much activity went on during any particular day for that server.
Now that we understand a bit more about how and where Windows 2000 server stores its IIS web logs, let’s look at how we can gain access to them through as ASP Script.