Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TextWriterTraceListener File sharing...

Status
Not open for further replies.

Kris11

Programmer
Jan 31, 2003
278
US
Anybody know how to share log file between multiple instances of the same application? Our application logs all the trace information to a text file, but the problem is that only one instance of the application gets the write access eventhough I have set the share and access to ReadWrite. Any idea how can I share the same log file between two instances? here is code that I have.

Code:
m_FileStream= m_FileInfo.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

m_TraceListener= new TextWriterTraceListener(m_FileStream);
Trace.AutoFlush= true; 
Trace.Listeners.Add(m_TraceListener);

If I run the app, only the first instance that I launched gets the write access and the second instance does not log any info.

-Kris
 
I would make the logging piece an application of its own. Your applications then send input requests to the app and the app handles it by itself.

If you want to get crazy about it: create a webservice that your logger calls.
 
Hmmm... Creating a stand-alone logging application sounds appealing, something that I need to think little more and need to see if I might end up with the same problem that I am facing now. I do not know how effectively I can convince my team to create a web-service for the logging part, especially when the app that I am working on is a winform app, anyway a good suggestion to put forward. Thanks for the suggestions.

-Kris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top