xml logging and locking

Topics: Logging Application Block
Jun 10, 2010 at 12:35 PM

Hi All

I have used the logging application block in a windows c# forms application, but it seems that the file is in use when the form is in use. Is it possible to close the file /listener so that I can read the file ?

Regards

Paul

 

 

Jun 10, 2010 at 4:37 PM

Hi Paul,

There is already a logged workitem for this issue http://entlib.codeplex.com/workitem/25265. As of now, as far as I know  there are still no any workaround found for this issue. Most advices are to use other trace listener like MSMQ or Database over Flat file trace listener if you intend to open/read the logentry.   

Gino Terrado
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Jun 11, 2010 at 8:35 AM
Edited Jun 11, 2010 at 9:20 AM

Hi Gino

Thanks for the quick reply,

Unfortunatly we have no choice but to use the xml listencer.

Inside our app we would like to be able to view the log file, and having it locked is a real pain ( not unusable ).

Or could I close the xml listner read the log file and then load the listeners again afterwards?

Would loggin using a different thread help. ?

Many thanks

Paul

 

Jun 11, 2010 at 9:54 AM

I believe you could read the file using the following code:

FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
StreamReader reader = new StreamReader(fs);
string log =  reader.ReadToEnd();

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jun 11, 2010 at 12:54 PM

Hi Sarah

Many thanks that worked great.

Regards

Paul