0

因此,我想将 .Net 应用程序从使用某些先前的手动转换方法转换为 Troy Hunt http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity 所引用的 xdt 样式。 .html _ 我目前对变换不太熟悉,我想我可能只需要朝着正确的方向发展。

如何转换以下内容以便可以更改网络配置中的文件路径 c:\logs\blah.log?

<log4net>
    <appender name="Asplogger" type="log4net.Appender.TraceAppender">
      <layout type="log4net.Layout.SimpleLayout" />
    </appender>
    <appender name="RollingAppender" type="log4net.Appender.RollingFileAppender">
      <file value="c:\logs\blah.log" />
      <appendToFile value="true" />
      <maximumFileSize value="1000KB" />
      <rollingStyle value="Size" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <appender name="NHibernate.SQL" type="log4net.Appender.TraceAppender">
      <layout type="log4net.Layout.SimpleLayout" />
    </appender>
    <logger name="NHibernate">
      <!--Namespace-->
      <level value="ERROR" />
      <!--level of errors to report INFO, ERROR, FATAL-->
    </logger>
    <logger name="NHibernate.SQL">
      <level value="ERROR" />
      <appender-ref ref="NHibernate.SQL" />
    </logger>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="RollingAppender" />
      <appender-ref ref="Asplogger" />
    </root>
  </log4net>

会是这样吗?

<log4net>
    <appender name="RollingAppender">
      <add xdt:Transform="Replace" xdt:Locator="Match(key)"
        key="file value" value="path.that.I.want"/>
    </appender>      
   </log4net>
4

1 回答 1

0

我想到了。您需要匹配名称而不是键

<log4net>
    <appender name="RollingAppender" xdt:Locator="Match(name)">
      <file xdt:Transform="SetAttributes" 
            value="path.that.I.want.log"/>
    </appender>
  </log4net>
于 2013-11-07T16:53:17.493 回答