所以我想将.Net应用程序转换为使用一些先前的手动转换方法转换为Troy Hunt http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity.html引用的xdt样式。我目前对变形不太熟悉,我想我可能只需要朝着正确的方向发展。
如何转换以下内容以便我可以在Web配置中更改文件路径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>
答案 0 :(得分:0)
我明白了。您需要匹配名称而不是键
<log4net>
<appender name="RollingAppender" xdt:Locator="Match(name)">
<file xdt:Transform="SetAttributes"
value="path.that.I.want.log"/>
</appender>
</log4net>