【问题标题】:Environment variable treated as string in app.config环境变量在 app.config 中被视为字符串
【发布时间】: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


【解决方案1】:

也许尝试其他环境变量,例如 %APPDATA%%ALLUSERSPROFILE%

【讨论】:

  • 同样的结果,难道是微软企业库在使用旧的?还是与它无关? (我无法弄清楚项目使用的是哪个版本!)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多