Logging on BeginRequest but file used by another process

F

Frank

Hi,

I'm logging requests by opening the log file on each
Application_BeginRequest event with:
StreamWriter log = File.AppendText(logFilename);

This works most of the time but sometimes I get an IOException with the
message:
The process cannot access the file <filename> because it is being used by
another process.

Can this be caused by requests that occurr at the same time? (Threading)
Or if its another process (e.g. Virus scanner) should I keep the file open?
Make StreamWriter log static?

Any ideas on how to prevent this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top