Is writting to a shared log file an issue for ASP.Net app?

G

Guest

I have an ASP.Net app that is wrtting some log information into a log file.
All I have is one single log file used by the web application and shared
cross all the sessions. What I don't understand is what will happen if one
session is trying to write the file while another is currently writting to
it. Is that going causing a conflict? Sometimes I saw messages like "...
can't access the file. it may be accessed by other process...". Could this be
because of that confilict or something else that's totally unrelated?

If some one could shed some light on this one it would be highly appreciated.

Thanks in advance.

feng
 
C

Craig Deelsnyder

Feng said:
I have an ASP.Net app that is wrtting some log information into a log file.
All I have is one single log file used by the web application and shared
cross all the sessions. What I don't understand is what will happen if one
session is trying to write the file while another is currently writting to
it. Is that going causing a conflict? Sometimes I saw messages like "...
can't access the file. it may be accessed by other process...". Could this be
because of that confilict or something else that's totally unrelated?

If some one could shed some light on this one it would be highly appreciated.

Thanks in advance.

feng

Yes, basically your one file is being locked as one thread
(user/request) has it opened for writing. Then another user/request
comes along and is denied access until it's released.

You'd either have to make it thread-safe yourself (synchronize/lock the
access to the file, which depending on load, performance may be
hindered), or use some other logging mechanism. I believe a framework
like log4net has taken care of this (logging to a flat file), and is the
quickest fix IMHO; see their GlobalContext class:

http://logging.apache.org/log4net/
 

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

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top