Previous Next

Thread: IIS Logfiles Location

Last post 08-15-2008 1:14 AM by steve schofield. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 08-13-2008, 3:05 PM

    • grnr_rchrd
    • Not Ranked
    • Joined on 09-02-2006, 7:09 AM
    • England
    • Posts 5

    IIS Logfiles Location

    I am trying to read the contents of IIS logfiles using C#, but I do not know how to find where they are. The physical location on my PC is C:\inetpub\logs\LogFiles\W3SVC1.

    In my software I am using:

    string serverName = "localhost";

    DirectoryEntry W3SVC = new DirectoryEntry("IIS://" + serverName + "/logs/logfiles/w3svc/1");

    foreach (DirectoryEntry d in W3SVC.Children)

    {

    MessageBox.Show(d.Name);

    }

    But it says the path does not exist. I am also not sure that the foreach will bring back each file within the directory anyway. I think it will bring back each child directory, which is not what I want.

    Can anyone point me in the right direction please.

    Richard
    Tags:
  • 08-14-2008, 10:35 AM In reply to

    Re: IIS Logfiles Location

    grnr_rchrd:
    I do not know how to find where they are. The physical location on my PC is C:\inetpub\logs\LogFiles\W3SVC1.

    Look in that folder and see if they really are there.  Check permissions on the file/folder.

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 08-14-2008, 4:06 PM In reply to

    • dac3636
    • Not Ranked
    • Joined on 06-22-2007, 4:25 PM
    • Posts 5

    Re: IIS Logfiles Location

     

    If all your trying to do is get the logfile names under that directory, try this.

    DirectoryInfo iisDir = new DirectoryInfo(@"C:\inetpub\logs\LogFiles\W3SVC1");

    FileInfo[] myfiles;

    myfiles = iisDir.GetFiles();

    foreach (FileInfo logfile in myfiles)

    {

    Console.WriteLine(logfile.Name.ToString());

    }

     Like the other reply said, make sure to check the security on the directory.

  • 08-15-2008, 1:14 AM In reply to

    Re: IIS Logfiles Location

    You are using the IIS provider, do you have the legacy tools installed?

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield

    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
Page 1 of 1 (4 items)
Page view counter