gpt4 book ai didi

log4Net 配置转换

转载 作者:行者123 更新时间:2023-12-02 00:13:21 32 4
gpt4 key购买 nike

我能够转换我的 log4net.config,但我没有得到这个。如何更改以下连接字符串?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net debug="true">
<root>
<level value="ALL" />
</root>
<logger name="MyApp">
<level value="Debug" />
<appender-ref ref="RollingLogFileAppender" />
<appender-ref ref="AdoNetAppender" />
</logger>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\Websites\Logs\SiteLog.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyyMMdd.txt"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
</layout>
</appender>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="***Data Source=(local);initial catalog=MyDB;User ID=sa;Password=dbPassword***" />

以下方法不起作用:

<?xml version="1.0" encoding="utf-8" ?>

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<log4net debug="false"
xdt:Transform="SetAttributes(debug)" />
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<connectionString value="Data Source=(local);initial catalog=RavenAxiom;User ID=ravenaxiom;Password=xyz"
xdt:Transform="SetAttributes(value)" />
</appender>
</configuration>

它更改了调试值,因此它可以部分工作。感谢您的帮助。

jack

最佳答案

好的,让它工作: appender name="AdoNetAppender" 中的 xdt:Locator="Match(name)" ,然后 xdt:Transform= connectionString value="NewConnValues" 中的“替换”

<configuration>
<log4net>
<appender name="AdoNetAppender"
type="log4net.Appender.AdoNetAppender"
xdt:Locator="Match(name)">
<connectionString value="YourConnectionStringToBe"
xdt:Transform="Replace"/>
</appender>
</log4net>
</configuration>

关于log4Net 配置转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7693837/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com