Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Perl CGl Programming: No experience required.
(Publisher: Sybex, Inc.)
Author(s): Erik Strom
ISBN: 0782121578
Publication Date: 11/01/97

Bookmark It

Search this book:
 
Previous Table of Contents Next


Setting the “Standard”: The UNIX Logging Format

The log format used by IIS is considered “non-standard”; in other words, it’s something new. The “old” standard is known as the UNIX Common Log Format, and it’s used on the NCSA and CERN servers.

Here’s an example log entry in the Common Log Format:

   website.com 140.172.165.58 admin [27/Apr/1997:20:47:43 -0700] "GET
   ⇒ session\adminlogin HTTP/1.0" 200 160

Again, this entry normally appears in one line, but is broken up here to fit on the page.


NOTE:  The format used by the Sambar server in itsaccess.log file is almost identical to the UNIX Common Log Format. The difference is that Sambar doesn’t attempt to decode the client IP address unless you tell it to, which isn’t recommended by Sambar because of all the processing time it takes. A Sambar entry starts with the IP. It also logs a Windows NT result code for each operation and inserts it between the server result code and the number of bytes sent.

The entries in the a Common Log Format log file are broken down in this way:

  Client’s domain name (not used by Sambar server)
  Client’s IP address
  Date and time of request
  Operation requested, plus the target of the operation and the HTTP version being used
  Result code from the server
  Number of bytes transferred

Figure 9.3 breaks out the components of a Common Log Format entry.


Figure 9.3:  The UNIX Common Log Format broken down.


NOTE:  UNIX Web servers have access to more built-in Internet software than Windows-based servers. This is why the UNIX CGI environment and the server log files contain client domain names as well as IP addresses. The only information the client sends, in most cases, is its IP address; the address is resolved into a name by the server. However, it isn’t too difficult to include the capability to resolve IP addresses into names on a Windows system. You’ll learn how to do it in Skill 12.


NOTE:  Note the format of the date and time stamp: [27/Apr/1997:20:47:43 -0700]. The date and time are easily picked out, but you may not be familiar with the –0700 that ends the string. This is a time zone value, indicating the number of hours that were added to Greenwich Mean Time (GMT) to obtain the correct local time, which is displayed in the string. In this example, –0700 says to subtract seven hours (note the – in front of it) from GMT. If you know your time zones, you’ll know that Mountain Standard Time is seven hours behind GMT. If you don’t know your time zones, it’s pretty easy to look them up somewhere, load them all into a table, and use it to calculate the correct zone with a Perl program. Also, all of the operating systems covered in this book are capable of correcting for Daylight Savings Time, and the date and time stamp in the log file will reflect this correction.

Making IIS Compatible with UNIX

If you’re using the Internet Information Server on your Web site, but you decide that you like the UNIX Common Log Format better than Microsoft’s format, it is easy to make IIS conform to your wishes.

The configuration program for the IIS Web server is found in the Internet Service Manager, which can be found on NT’s Start menu by choosing Programs [special character] Microsoft Internet Server. When you click Internet Service Manager, you’ll see a window containing a list of all the Internet services running on your computer. Click the line that shows WWW under Service, then click Properties [special character] Service Properties.

You will see a Logging tab on the property sheet that appears. Click it and it moves to the front. A window similar to the illustration in Figure 9.4 will be displayed.


Figure 9.4:  The Logging options for Internet Information Server

Notice the Log Format list box under Log to File. If you click it, you will see two choices: Standard Format and NCSA Format. Microsoft, of course, considers its format to be the standard, so it refers to the UNIX format as “NCSA,” a nod to the popular UNIX Web server. If you choose NCSA Format, IIS will then start logging entries in the Common Log Format.


NOTE:  Any changes made to the IIS Web server configuration won’t take effect until you stop the server and restart it. You can do this from Internet Service manager, too, by clicking the Stop Service button on the toolbar, then clicking the Start Service button.

The Logging property sheet in Internet Service manager is also where you tell IIS how to structure logging in general. The default installation sets up a directory of log files, one file for each day. The files are named in the format SVCYYMMDD.log, where SVC refers to either IIS or NCSA log formats and YY, MM, and DD are the year, month, and date, respectively. In IIS format, the server log for August 23, 1997, would be named in970823.log. The “in” is replaced with “nc” in NCSA format.

You have several other choices if you don’t like this daily logging scheme. A new log file can also be created every week, every month, or when the file reaches a size that you specify in megabytes. Just click the radio button of your choice and IIS will follow the new scheme.


TIP:  If you change the IIS logging scheme, notice that the file-naming format changes, too. The current format is shown under Log file name: at the bottom of the Logging property sheet.

Extracting Log File Information

You have learned about the formats for Web server log files and where they are kept by the various servers. Now, what can you do with all of the information in the logs?

Perl is especially adept at handling projects that involve processing “formatted” text, much more so than a higher-level compiled language such as C or C++ is. Let’s see how it’s done.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.