IIS Home @ it-notebook.org

Exclude IP addresses from log file; Difference IIsWebDirectory and IIsWebVirtualDir

(Kristofer Gafvert, October 05, 2007)


Each week I take two questions from the IIS newsgroups (or IIS forums) that I think is of public interest, and I answer them here as well. Questions and answers may be modified to be more general and more useful for everyone.

Exclude certain IP addresses from log file

I have a website monitor application that requests certain pages to ensure that the website is up and running. This does however affect the statistics, and I do not want the requests from this application to be logged. Can I setup logging so that requests from a specified IP address are not logged?

No, you cannot tell IIS to not log requests that are coming from a certain IP address. You can however exclude certain folders and/or files from being logged. So if your monitoring application is requesting the same file each time, you can exclude requests (all requests, from all clients) for this file from being logged.

The second option is to exclude your monitoring server's IP address when you analyze the log files. Any decent log analyzer should be able to do this.

The third option is to use Log Parser and remove any entries originating from the monitoring server's IP address, prior to running your analyzing software. The SQL query to use in Log Parser would be:

select * into NewFileName.log from 'c:\path\to\file.log' where c-ip <> 'IP_Address_of_monitoring_server'

The difference between IIsWebDirectory and IIsWebVirtualDir

I am writing an installation package for an ASP.NET web application. Should I be creating the application root as a IIsWebDirectory or IIsWebVirtualDir? What is the difference between them?

IIsWebDirectory and IIsWebVirtualDir are almost the same, except for one thing - IIsWebDirectory cannot map an URL to a physical folder (it does not support the Path property. For example, if you have a folder named webApplication in D:\folder\webApplication but your website is in c:\inetpub\wwwroot, you must use IIsWebVirtualDir because IIsWebDirectory cannot map d:\folder\webApplication to (for example) http://localhost/webApplication.

IIsWebDirectory is used to set URL metadata on a specific folder that exists beneath the webroot. For example, you want to disable logging on a folder in C:\inetpub\wwwRoot\folder, you would set up "folder" as a IIsWebDirectory and set its DontLog property to 1. (The very same thing can be done by using IIsWebVirtualDir.)

So when you deploy an ASP.NET application, it depends on where (on the file system) it is located whether to use IIsWebDirectory or IIsWebVirtualDir.

Applies to [?]

IIS 6.0