IIS (2/9)

Setting up logging

An important feature of any web server is to log the requests it receives. If you are following this tutorial step by step though your web server won't be doing any logging. This is because even logging is a feature you can turn on and off in the control panel. As can be seen on figure 1 the logging feature is under the "Health and Diagnostics" section and is called "HTTP Logging".

IIS Logging Setup
Figure 1: Enabling logging support

Now that we have enable logging a new icon will be present in the IIS Manager. This is shown in figure 2 below.

IIS Manager with logging support enabled
Figure 2: The IIS Manager screen with logging support enabled

Selecting the newly installed Logging icon will display the screen shown in figure 3. For now we'll just use the default settings.

IIS Manager logging setup
Figure 3: The logging options screen in the IIS Manager

Using the logs

We can see that the default log location is in C:\inetpub\logs. If we navigate to that location we find a log file in the path: C:\inetpub\logs\LogFiles\W3SVC1\u_ex131019.log. The default log settings create 1 log file per day and this is what the 131019 stands for in the file name, 19 Oct 2013, the date at which this tutorial was written.

There are 2 points to be aware of before we look at the contents of the log:

  1. Writing to the log seems to be buffered, so you may not immediately see entries corresponding to recent requests.
  2. Web browser use a cache so you may have to force a refresh to get the browser to actually send the request to the web server.

Let's now look at the some log contents. We have chosen the W3C format for the logs since that is the default. MOre information on that file format and the other available formats is available here. Let's assume we have made 2 requests: one to get http://localhost and the other one to get http://localhost/doesnotexist. The log would look like this:

Log contents
2013-10-19 11:59:31 ::1 GET / - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+Touch;+rv:11.0)+like+Gecko - 304 0 0 15
2013-10-19 12:00:24 ::1 GET /doestnotexist - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+Touch;+rv:11.0)+like+Gecko - 404 0 2 0

For the first request we get a 304 status code, telling the browser that its cached copy of the page is fresh. For the second request we get a 404 code because the page couldn't be found.


blog comments powered by Disqus

Copyright(c) 2006-2017 Xavier Leclercq | Privacy policy

Home
Contact Us
Search