I’m using TextWriterTraceListener to ouptput my trace information to a log file. Unfortunately it locks the logfile and I am not able to open it externally while the application is running. Any way to make this possible?
I’m using TextWriterTraceListener to ouptput my trace information to a log file. Unfortunately it
Share
It depends what constructor you used. The TextWriterTraceListener(String) constructor creates a StreamWriter that opens the file with FileShare.Read. That allows any process to read the file.
The usual problem is trying to open the file with the wrong FileShare setting in the other process. You have to specify FileShare.ReadWrite. The trace listener has already gained write access to the file, you cannot deny it.