In IIS7, you can use the Microsoft.Web.Administration assembly, the Site class has a property called LogFile , you can get various information about the log file for the site, for example, the directory of log files can be obtained using this code:
ServerManager manager = new ServerManager(); Site mySite = manager.Sites["SiteName"]; Response.Write("Log file directory : " + mySite.LogFile.Directory + "\\W3svc" + mySite.Id.ToString());
I donβt really like this hardcoded part with the directory prefix for the site, but did not find another better way
Antonio Bakula
source share