【问题标题】:ASP.NET Configuration Transform not workingASP.NET 配置转换不起作用
【发布时间】:2019-07-11 09:10:30
【问题描述】:

这是我的(简称)Web.config

<configuration>
  [...]
  <nlog autoReload="true" throwExceptions="false" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <targets>
      <target xsi:type="File" name="file" layout="[...]" />
    </targets>
    <rules>
      <logger name="*" minlevel="Trace" writeTo="file" />
    </rules>
  </nlog>
</configuration>

这是我的Web.Release.Config

<configuration>
  <nlog>
    <rules>
      <logger name="*" minlevel="#{Something}#" writeTo="file" xdt:Transform="SetAttributes" xdt:Locator="Match(writeTo)" />
    </rules>
  </nlog>
</configuration>

但是没有发生任何转换。我在ConfigurationTransform 输出窗口中也看不到任何错误或警告...

我在这里做错了什么?

【问题讨论】:

    标签: asp.net web-config


    【解决方案1】:

    问题是发布配置中的nlog 元素位于不同的namespace 中,您需要包括:

    <configuration>
      <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd">
        <rules>
          <logger name="*" minlevel="#{Something}#" writeTo="file"
              xdt:Transform="SetAttributes" xdt:Locator="Match(writeTo)" />
        </rules>
      </nlog>
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 2012-02-09
      • 1970-01-01
      • 2014-10-06
      • 1970-01-01
      • 2012-08-02
      • 1970-01-01
      • 1970-01-01
      • 2011-07-11
      • 2020-04-03
      相关资源
      最近更新 更多