/// <summary> /// 使用配置节点对当前配置进行初始化。 /// </summary> /// <param name="configuration">对应的配置节点。</param> public override void Bind(IConfiguration configuration) { Bind(configuration, "settings", func: c => new LoggingConfigurationSetting { Name = c.Key, LogType = Type.GetType(c.GetSection("type").Value, false, true) }); DefaultInstanceName = configuration.GetSection("default").Value; Level = LogEnvironment.GetLevel(configuration.GetSection("level").Value); base.Bind(configuration); }
/// <summary> /// 使用配置节点对当前配置进行初始化。 /// </summary> /// <param name="section">对应的配置节点。</param> public override void Initialize(XmlNode section) { InitializeNode(section, "logging", func: node => new LoggingConfigurationSetting { Name = node.GetAttributeValue("name"), LogType = Type.GetType(node.GetAttributeValue("type"), false, true) }); //取默认实例 DefaultInstanceName = section.GetAttributeValue("default"); Level = LogEnvironment.GetLevel(section.GetAttributeValue("level")); base.Initialize(section); }
IConfigurationSettingItem IConfigurationSettingParseHandler.Parse(IConfiguration configuration) { var setting = new ComplexLoggingSetting(); setting.LogType = Type.GetType(configuration.GetSection("type").Value, false, true); foreach (var child in configuration.GetSection("loggers").GetChildren()) { var level = LogEnvironment.GetLevel(child.GetSection("level").Value); var logType = Type.GetType(child.GetSection("type").Value, false, true); if (logType != null) { setting.Pairs.Add(new ComplexLoggingSettingPair { Level = level, LogType = logType }); } } return(setting); }
IConfigurationSettingItem IConfigurationSettingParseHandler.Parse(XmlNode section) { var setting = new ComplexLoggingSetting(); setting.LogType = Type.GetType(section.Attributes["type"].InnerText, false, true); foreach (XmlNode node in section.SelectSingleNode("loggers").ChildNodes) { var level = LogEnvironment.GetLevel(node.Attributes["level"].InnerText); var logType = Type.GetType(node.Attributes["type"].InnerText, false, true); if (logType != null) { setting.Pairs.Add(new ComplexLoggingSettingPair { Level = level, LogType = logType }); } } return(setting); }