Using Isolated Storage to store logging flat file or xml file

Topics: Logging Application Block
Aug 17, 2010 at 10:57 AM
Hi, I am experimenting with the Logging block in my web & WCF application. I've am using V5 and added the logging block with the event log listener. This works. I want to store my log info in isolated storage to avoid ACL issues for my web application but I can't see any way to specify this in the file name. Any suggestions? Thanks
Aug 18, 2010 at 3:04 AM

Hi,

Sorry, its a bit unclear to me, (I'm really not sure if this is what you're asking) do you mean specifying the isolated storage location? If yes, hope this http://msdn.microsoft.com/en-us/library/3ak841sy(v=VS.100).aspx#isolated_storage_locations helps.

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

 

Aug 18, 2010 at 6:05 AM

I currently use an XML Trace Listener:

 

add   name = "XML Trace Listener " type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

.....

fileName="c:\data\Log.xml" traceOutputOptions="LogicalOperationStack, DateTime"

/>

I want to change the file location to Isolated Storage. So what should I specify in filename to store the log file in Isolated Storage?

Thanks

 

Aug 18, 2010 at 6:15 AM

The link I provided earlier (http://msdn.microsoft.com/en-us/library/3ak841sy(v=VS.100).aspx#isolated_storage_locations) should point you on the location of the Isolated Storage depending on your OS.

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

Aug 18, 2010 at 5:25 PM

Beware - just pointing the path name at where isolated storage happens to be on disk is a bad idea. This changes with each application, each user, and probably with each CLR version or patch.

The real answer here is that the default trace listeners don't do this, you'll need to write a custom one (can just copy most of the logic from the existing one) that uses the isolated storage API instead of the standard file IO api to write the log message.