I am using the code from this post IIS 7 Log Request Body so that I can see what is happening when people attempt to access my site.
protected void Application_BeginRequest(Object sender, EventArgs e)
{
var uniqueid = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
var logfile = String.Format("C:\\logs\\{0}.txt", uniqueid);
Request.SaveAs(logfile, true);
}
When it runs though, I am getting this message:
The process cannot access the file 'C:\logs\635256490792288683.txt' because it is being used by another process.
Every once in a while, people are having the of no response from the site and I desperately need to find out what is happening.
Any idea how to resolve this?
The resolution of DateTime.Now
is not good enough for what you are trying to do. For a quick fix, you could use new Guid().ToString();
but dont do this in production, it is going to really hurt your site performance.