Hi,

Just note that the logging location can be set at the web server, web site, 
folder and file level (in case you are using this code for someone else's IIS 
server)

Cheers
Ken

From: [email protected] [mailto:[email protected]] On 
Behalf Of Greg Keogh
Sent: Saturday, 9 April 2011 10:23 AM
To: 'ozDotNet'
Subject: RE: Getting IIS web logging folders

Thanks to Michael for the following code clue which starts the IIS directory 
search higher up the tree.



foreach (DirectoryEntry Site in new DirectoryEntry("IIS://" + 
System.Environment.MachineName + "/w3svc").Children)

{

  if (String.Compare(Site.SchemaClassName, "IIsWebServer", 
StringComparison.OrdinalIgnoreCase) == 0)

  {

    Console.WriteLine(Site.Properties["ServerComment"].Value.ToString());

    Console.WriteLine(Site.Properties["LogFileDirectory"].Value.ToString());

  }

}

If you start here you can get the properties of each web site. The Name of each 
Site in the code above can be "1", "2", etc which enumerates the N sites and 
you can then append /N/ROOT to the uri and drill down into each site as I did 
in my previous code.

Now I have the log files location, I've hit another technical stumbling block 
on reading the files. I'll post separately about this.

Greg

Reply via email to