0

I've developed a WinForms app that I've that shows the bandwidth a single IIS site using LogParser. This worked quite well.

I've now written the exact same thing in ASP.net, but then the following exception is thrown: Cannot find any file matching "C:\inetpub\logs\LogFiles\W3SVC4\ex*.log"

The exception makes sence, since all our log files are prefixed with 'u_ex' and not 'ex' (default IIS settings I guess). It's just strange that it does work when ran from a WinForms application and not when put in a WebApp.

Does anyone know why this happens and how I can fix it?

Thanks!

Here's a chuck of the code I'm using:

private void UpdateByDateRange(DateTime dateFrom, DateTime dateTo) 
{

string siteId = Request.ServerVariables["INSTANCE_ID"]; 
LogQueryClassClass logger = new LogQueryClassClass();

COMIISW3CInputContextClass inputContext = new COMIISW3CInputContextClassClass(); 
string query = "SELECT SUM(TO_REAL(sc-bytes)) AS sentTotal, SUM(TO_REAL(cs-bytes)) AS receivedTotal FROM <" + siteId + "> WHERE TO_TIMESTAMP(date, time) >= TO_TIMESTAMP('" + dateFrom.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-MM-dd HH:mm:ss') AND TO_TIMESTAMP(date, time) <= TO_TIMESTAMP('" + dateTo.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-MM-dd HH:mm:ss')";

ILogRecord record = logger.Execute(query, inputContext).getRecord(); 
decimal trafficSent = decimal.Parse(record.getValue("sentTotal").ToString());

decimal trafficReceived = decimal.Parse(record.getValue("receivedTotal").ToString()); 
// ...

}
AnonJr
  • 2,759
  • 1
  • 26
  • 39

1 Answers1

0

Does AspNet have permissions to the C:\inetpub\logs\LogFiles\W3SVC4\ folder? This error normally occurs when the file doesn't exist OR the runtime does not have permissions. As an Asp.Net app, you need to ensure that the AspNet account has access to this folder or run the web site under another account that does have access.

This older post might help.

ASPNET user does not have write access to Temporary ASP.NET Files

Community
  • 1
  • 1
David
  • 72,686
  • 18
  • 132
  • 173