Stop writing Log file sporadically

Topics: Logging Application Block
Feb 3, 2012 at 12:51 AM

I have a wcf service and I write log from inside this service. The log is written to a text file which will create a new file whenever the size becomes 1024 KB.

The location of the log is inside a subfolder the service is hosted.

The issue is sometimes, the log is not written. I cannot find the log written the folder. When I recycle the application pool of the WCF service , it starts working again.  I cannot find what is happening here. Just want to ask you guys anybody face the similar issues before.

Also, which account will be used to write to the log file. I use an impersonated account ( from the web.config of the service) for the WCF operation. 

Appreciate your help

Feb 3, 2012 at 4:58 AM
Edited Feb 3, 2012 at 4:59 AM

It sounds like you are using the Rolling Flat File Trace Listener.  I have seen instances where the main log file can be written to but the new archived (rolled) log file cannot be created due to permission problems.  This could be what you are encountering.

Have you configured the errors special source?  That may let you see any exceptions.  Usually, I recommend using a flat file trace listener but since you are using impersonation perhaps the Event Log trace listener would be a better choice.  Just ensure that the event source is created because your users won't have permission to write to the registry to create the event source (at least I hope they wouldn't!).  

I believe if you are using impersonation then the file IO will be performed as that user. 

Randy Levy
Enterprise Library support engineer 

Feb 3, 2012 at 4:07 PM

Thanks Randy, I will try what you suggested.!