///
/// 重新配置log4net 改为默认数据库连接
///
public static void ConfigureLog4Net()
{
log4net.Config.XmlConfigurator.Configure();
log4net.Repository.Hierarchy.Hierarchy hierarchy = log4net.LogManager.GetRepository() as log4net.Repository.Hierarchy.Hierarchy;
if (hierarchy != null && hierarchy.Configured)
{
foreach (log4net.Appender.IAppender appender in hierarchy.GetAppenders())
{
if (appender is log4net.Appender.AdoNetAppender)
{
var adoNetAppender = (log4net.Appender.AdoNetAppender)appender;
adoNetAppender.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
adoNetAppender.ActivateOptions();
}
}
}
}