How do I configure the Enterprise Library Logging Application Block to place the log files in the ProgramData folder? AFAIK it's only possible to use relative paths (from the installation directory) or absolute paths to set the location in EntLib configuration.
+3
A:
You can also use (most) environment variables in the fileName path. ProgramData folder environment variable is %ALLUSERSPROFILE%, so you could set up your configuration file something like this:
<add
fileName="%ALLUSERSPROFILE%\MyApplication\Logs\trace.log"
header=""
footer=""
formatter="Text Formatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"
name="Flat File Destination" />
Tuzo
2010-05-31 15:26:58
That's just awesome, thank you: Works as advertized! :)
Jakob Gade
2010-06-01 13:38:21