Use of %TEMP% in Logging Block

Topics: Logging Application Block
May 16, 2011 at 6:43 PM
Edited May 16, 2011 at 6:49 PM

I would like to make use of this new feature in Entlib 5.0, however when I enter this string "%TEMP%\appLog.log" as the Filename property for my Xml Trace Listener, I receive an error, due to entlib using my string as a relative path. Entlib tries to create a path of C:\.....path to app working directory........\%TEMP%\appLog.log which is obviously not correct.

Can someone help me out with what I am doing wrong?

May 17, 2011 at 5:18 AM

Hi,

I tried your scenario and I was able to reproduce it though I didn't get any errors, its just that it did not create the output file. I tried to translate it to an absolute path and it worked fine. On the other hand, i tried "%TEMP%\appLog.log" but by using Rolling Flat File Listener instead and it worked too. So I suspect that this issue is reproducible only to XmlTraceListener. I'm not sure if this is really a bug with Enterprise Library or a behavior inherent to System.Diagnostics.XmlWriterTraceListener (since XmlTraceListener inherits from it). A workaround I can think of is by using the Fluent Configuration API as described on this thread. Hope this helps.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 17, 2011 at 1:15 PM
Edited May 17, 2011 at 1:43 PM

Thank you Noel, I did try it with a Rolling Flat file and found it worked just fine, so I will just skipi the Xml log at this stage. I believe it may be a bug as it mentions the use of the environment variables in the Filename property under the Xml Trace Listener type in the MSDN doco here - http://msdn.microsoft.com/en-us/library/ff664768(v=pandp.50).aspx

EDIT (additional info) - and yes there were no errors, except I was debugging and throwing all exceptions so I was able to see the DirectoryNotFound exception which is throw by the Logging block internally.

May 18, 2011 at 9:13 AM

Thanks for pointing this out. I've already logged this to our issue tracker found here. You can vote for this one so that the Enterprise Library team will be aware on the issue.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com