Logging Directory

Topics: Logging Application Block
Nov 20, 2008 at 6:05 PM
I am using a configuration file to have the logging application block create a rolling flat file.  Is there a key word or another approach that can be added to the configuration file that would create the log file in the currrent user's My Documents directory.

I am trying to avoid using code to change it or having each user change the configuration file.
Nov 21, 2008 at 2:21 AM
Hi,

You can try using the environment variables as a part of the path of the rolling filename. You can set the filename of the Rolling Flat File Trace Listener to something like this :
%USERPROFILE%\My Documents\rolling.log


Use environment variables with logging as described here:
http://msdn.microsoft.com/en-us/library/cc511699.aspx#trace_flatfile


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Nov 21, 2008 at 10:55 AM
Thanks this appeared to be what I was looking for however when I use an environment variable, it is creating a directory under my executing application with the environment variable as the directory name (e.g. filename="%USERPROFILE%\My Documents\rolling.log" actually wrote to C:\Program Files\MyApp\%USERPROFILE%\My Documents\rolling.log

I originally thought it was because the environment variable did not exist so I looked and found %TEMP% which was also described in the article you provided and it exibited the same behavior.
Nov 21, 2008 at 1:59 PM

Hi,

That's strange, i tried it our earlier but it does the logging in the expected directory. Are you using Ent lib 4? What is your OS? would you mind sending me you sample solution so i can investigate further?

 

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com