好多时候,在lognet中再写一次连接都是重复的,通过下面的方法可以读取在配置文件其它位置声明的数据库连接

在其他地方读取Log4net的数据库连接using System;
在其他地方读取Log4net的数据库连接
using log4net;
在其他地方读取Log4net的数据库连接
using log4net.Config;
在其他地方读取Log4net的数据库连接
using System.Configuration;
在其他地方读取Log4net的数据库连接
using System.Collections.Specialized;
在其他地方读取Log4net的数据库连接
using System.IO;
在其他地方读取Log4net的数据库连接
namespace EtpService.Core

调用代码:
在其他地方读取Log4net的数据库连接private static readonly ILog log = LogManager.GetLogger(typeof(AccountManager));
在其他地方读取Log4net的数据库连接
string conString = Log4net.GetConfig("nhibernate",3);
在其他地方读取Log4net的数据库连接            Log4net.ConfigConnection(conString,
"EtpService.Core.AccountManager","ADONetAppender");
在其他地方读取Log4net的数据库连接没有用上面的类生成Log,不知道怎么实现 类似static 
readonly 的功能

配置文件:
在其他地方读取Log4net的数据库连接<configSections>
在其他地方读取Log4net的数据库连接        
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
在其他地方读取Log4net的数据库连接        
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
在其他地方读取Log4net的数据库连接        
<section name="etp" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
在其他地方读取Log4net的数据库连接    
</configSections>
在其他地方读取Log4net的数据库连接
<nhibernate>
在其他地方读取Log4net的数据库连接        
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
在其他地方读取Log4net的数据库连接        
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
在其他地方读取Log4net的数据库连接        
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
在其他地方读取Log4net的数据库连接        
<add key="hibernate.connection.connection_string" value="Password=sa;uid=sa;Initial Catalog=Etp;Data Source=dinghao" />
在其他地方读取Log4net的数据库连接    
</nhibernate>

相关文章:

  • 2021-07-13
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2021-08-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-07-13
  • 2021-11-21
相关资源
相似解决方案