/// <summary> /// Carga los datos de instrumentación del archivo de configuración en /// <see cref="PerformanceCounterContainer"/> /// </summary> public static void LoadConfiguration() { InstrumentationSection section = null; try { section = ConfigurationManager.GetSection( instrumentationSectionName) as InstrumentationSection; } catch (ConfigurationErrorsException ceex) { throw new InstrumentationException(string.Format( Messages.ErrorGettingConfigurationSection, instrumentationSectionName), ceex); } if (section != null) { LoadConfigurationFromConfigurationSection(section); } else { LoadConfigurationFromDefaultConfiguration(); } }
public void Formatters() { InstrumentationSection section = ConfigurationManager.ConfigurationSection; Assert.AreEqual(typeof(DateTimeFormatter), Type.GetType(section.Formatters[0].Type)); Assert.AreEqual(typeof(GenericFormatter), Type.GetType(section.Formatters[1].Type)); }
public void Messages() { InstrumentationSection section = ConfigurationManager.ConfigurationSection; Assert.AreEqual("textMessage", section.Messages[0].Name); Assert.AreEqual(typeof(TextMessage), Type.GetType(section.Messages[0].Type)); }
public void Bindings() { InstrumentationSection section = ConfigurationManager.ConfigurationSection; Assert.AreEqual("consolePersister", section.Bindings[0].PersisterName); Assert.AreEqual("*", section.Bindings[0].Severity); Assert.AreEqual("*", section.Bindings[0].Source); Assert.AreEqual("*", section.Bindings[0].Message); Assert.AreEqual("nullPersister", section.Bindings[1].PersisterName); Assert.AreEqual("Exception,Error", section.Bindings[1].Severity); Assert.AreEqual("*", section.Bindings[1].Source); Assert.AreEqual("textMesssage", section.Bindings[1].Message); }
public void Persisters() { InstrumentationSection section = ConfigurationManager.ConfigurationSection; Assert.AreEqual(3, section.Persisters.Count); Assert.AreEqual("consolePersister", section.Persisters[0].Name); Assert.AreEqual(typeof(ConsolePersister), Type.GetType(section.Persisters[0].Type)); Assert.AreEqual("{Time:yyyy-MM-dd hh:mm:ss.fff} - {Severity:-20} - {Source:-30} - {Message}", section.Persisters[0].CustomProperties["formatString"].Value); Assert.AreEqual("tracePersister", section.Persisters[1].Name); Assert.AreEqual(typeof(TracePersister), Type.GetType(section.Persisters[1].Type)); Assert.AreEqual("{Time:yyyy-MM-dd hh:mm:ss.fff} - {Severity} - {Source} - {Message}", section.Persisters[1].CustomProperties["formatString"].Value); }
/// <summary> /// Carga la configuración a partir de <paramref name="section"/> /// </summary> /// <param name="section">Sección de configuración del archivo de configuración</param> private static void LoadConfigurationFromConfigurationSection( InstrumentationSection section) { foreach (PerformanceCounterCategoryElement categoryElement in section.CategoryCollection) { PerformanceCounterContainer.AddPerformanceCounterCategory(categoryElement.Name, categoryElement.Description, categoryElement.IsActive, categoryElement.Type); foreach (PerformanceCounterElement counterElement in categoryElement.PerformanceCounterCollection) { PerformanceCounterContainer.AddCounter(categoryElement.Name, counterElement.Name, counterElement.Description, counterElement.Type); foreach (PerformanceCounterInstanceElement instanceElement in counterElement.InstanceCollection) { PerformanceCounterContainer.AddCounterInstance(categoryElement.Name, counterElement.Name, instanceElement.Name, instanceElement.IsActive); } } } }