Note that there are some explanatory texts on larger screens.

plurals
  1. POEnterprise Logging not translating environment variables in XML Trace Listener fileName specification
    primarykey
    data
    text
    <p>I am using Microsoft Enterprise Library 5.0 Optional Update 1 for logging. I've got a declared section in my app.config file as follows:</p> <pre><code> &lt;loggingConfiguration name="LLamasoftLoggingConfiguration" tracingEnabled="true" defaultCategory="General"&gt; &lt;listeners&gt; &lt;add name="XML Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.XmlTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="%ALLUSERSPROFILE%\CompanyName\AppName\Diagnostics\ErrorLog.xml" traceOutputOptions="None" /&gt; &lt;/listeners&gt; ... &lt;/loggingConfiguration&gt; </code></pre> <p>When I run the application and get down to using the logging, e.g.,</p> <pre><code> logWriter = Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.Current.GetInstance&lt;LogWriter&gt;(); logWriter.Write(logEntry); </code></pre> <p>I'll get a DirectoryNotFoundException with the text: Could not find a part of the path <code>'D:\Project\Application\bin\x86\Debug\%ALLUSERSPROFILE%\CompanyName\AppName\Diagnostics\ErrorLog.xml'.</code></p> <p>When I use an absolute path like <code>'C:\ProgramData\CompanyName\AppName\Diagnostics\ErrorLog.xml'</code> it works.</p> <p>I see a number of references saying I should be able to use environment vars in the log file path but, no matter which I try, they get appended to the current execution directory path. The references also say that the logging system will create the folder if it does not exist but I have to ensure that it exists.</p> <p>This is my first use of the Enterprise Logging application block so I don't know whether the behavior has changed between versions and if this one just has these quirks. For now, I've hard-coded the path into my app.config file but for the final version this should be dynamically determined.</p> <p>Suggestions appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload