【发布时间】:2019-06-15 09:48:43
【问题描述】:
在为 Microsoft Enterprise Library 声明侦听器文件名时,我无法使用任何环境变量 - 日志记录块
它被视为字符串“我在 exe 文件旁边找到一个名为 %temp% 的文件夹!
我尝试了多个变量都具有相同的结果,我尝试使用 ${} 格式和相同的结果!
<add fileName="%ProgramData%\errors.log" header="----------------" footer="----------------" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, OceanEhr.Logging" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener" name="UserLog"/>
微软文档提到我们可以在文件名中使用变量,所以不知道我错过了什么
来源:https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ff664768(v=pandp.50)
【问题讨论】:
-
改用
${ProgramData}。 -
我已经尝试并得到了与问题中所述相同的结果。谢谢
标签: c# logging environment-variables app-config enterprise-library