Hello,
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());
// ...
}