protected override Type GetConfigurationType(string formatterName) { LoggingConfigurationView loggingConfigurationView = (LoggingConfigurationView)CreateConfigurationView(); FormatterData data = loggingConfigurationView.GetFormatterData(formatterName); return(GetType(data.TypeName)); }
protected override Type GetConfigurationType(string sinkName) { LoggingConfigurationView loggingConfigurationView = (LoggingConfigurationView)CreateConfigurationView(); SinkData data = loggingConfigurationView.GetSinkData(sinkName); return(GetType(data.TypeName)); }
/// <summary> /// Get the configuration type for the type of <see cref="ILogDistributionStrategy"></see> /// </summary> /// <param name="distributionName">Name of distribution strategy as defined in configuration</param> /// <returns>A <see cref="Type"></see> instance describing the type of <see cref="ILogDistributionStrategy"></see> to be instantiated</returns> protected override Type GetConfigurationType(string distributionName) { LoggingConfigurationView loggingConfigurationView = (LoggingConfigurationView)CreateConfigurationView(); DistributionStrategyData data = loggingConfigurationView.GetDistributionStrategyData(distributionName); return(GetType(data.TypeName)); }
/// <summary> /// <para> /// Initializes the provider with its name and any attributes associated with the provider. /// </para> /// </summary> /// <param name="configurationView">A <see cref="LoggingConfigurationView"></see> object.</param> public override void Initialize(ConfigurationView configurationView) { ArgumentValidation.CheckForNullReference(configurationView, "configurationView"); ArgumentValidation.CheckExpectedType(configurationView, typeof (LoggingConfigurationView)); this.loggingConfigurationView = (LoggingConfigurationView) configurationView; }
/// <summary> /// <para> /// Initializes the sink with its name and any additional attributes. /// </para> /// </summary> /// <param name="configurationView">Dynamic view into the configuration information needed by the <see cref="MsmqSink"></see></param> public override void Initialize(ConfigurationView configurationView) { ArgumentValidation.CheckForNullReference(configurationView, "configurationView"); ArgumentValidation.CheckExpectedType(configurationView, typeof(LoggingConfigurationView)); this.loggingConfigurationView = (LoggingConfigurationView)configurationView; }
/// <summary> /// <para> /// Initializes the provider with its name and any attributes associated with the provider. /// </para> /// </summary> /// <param name="configurationView">Dynamic view into the configuration information needed by the <see cref="MsmqLogDistributionStrategy"></see></param> public override void Initialize(ConfigurationView configurationView) { ArgumentValidation.CheckForNullReference(configurationView, "configurationView"); ArgumentValidation.CheckExpectedType(configurationView, typeof(LoggingConfigurationView)); LoggingConfigurationView loggingConfigurationView = (LoggingConfigurationView)configurationView; DistributionStrategyData distributionStrategyData = loggingConfigurationView.GetDistributionStrategyData(ConfigurationName); ArgumentValidation.CheckExpectedType(distributionStrategyData, typeof(MsmqDistributionStrategyData)); msmqDistributionStrategyData = (MsmqDistributionStrategyData)distributionStrategyData; }
/// <summary> /// Initialize a new instance of a <see cref="TextFormatter"/>. Reads the template from /// configuration parameters. /// </summary> /// <param name="configurationView">Dynamic view into the configuration information needed by the <see cref="TextFormatter"></see></param> public override void Initialize(ConfigurationView configurationView) { ArgumentValidation.CheckForNullReference(configurationView, "configurationView"); ArgumentValidation.CheckExpectedType(configurationView, typeof(LoggingConfigurationView)); LoggingConfigurationView loggingConfigurationView = (LoggingConfigurationView)configurationView; FormatterData formatterData = loggingConfigurationView.GetFormatterData(ConfigurationName); ArgumentValidation.CheckExpectedType(textFormatterData, typeof(TextFormatterData)); textFormatterData = (TextFormatterData)formatterData; RegisterTemplate(); }
public void TestConfigureTraceListenerProperty() { LoggingSettings loggingSettings = new LoggingSettings(); LoggingConfigurationView loggingConfigView = new LoggingConfigurationView(loggingSettings); string propName1 = "diagnosticServiceEndpoint"; string propValue1 = "diagnosticServiceEndpointValue"; string propName2 = "diagnosticStorageAccount"; string propValue2 = "diagnosticStorageAccountValue"; loggingConfigView.AddTraceListener(OnPremisesBufferedTraceListener.ListenerName, OnPremisesBufferedTraceListener.ListenerTypeName); loggingConfigView.ConfigureTraceListenerProperty(OnPremisesBufferedTraceListener.ListenerName, propName1, propValue1); loggingConfigView.ConfigureTraceListenerProperty(OnPremisesBufferedTraceListener.ListenerName, propName2, propValue2); OnPremisesBufferedTraceListenerData listenerData = loggingSettings.TraceListeners.Get(OnPremisesBufferedTraceListener.ListenerName) as OnPremisesBufferedTraceListenerData; Assert.IsNotNull(listenerData); Assert.AreEqual(propValue1, listenerData.DiagnosticServiceEndpoint); Assert.AreEqual(propValue2, listenerData.DiagnosticStorageAccount); }
private void SetName() { LoggingException ex = new LoggingException(SR.InstallerCannotReadServiceName); this.serviceName = DistributorService.DefaultApplicationName; string path = Directory.GetCurrentDirectory(); using (ConfigurationContext context = ConfigurationManager.CreateContext(Path.Combine(path, ConfigurationFileName))) { LoggingConfigurationView view = new LoggingConfigurationView(context); DistributorSettings settings = view.GetDistributorSettings(); if (settings.DistributorService == null) { throw ex; } if (settings.DistributorService.ServiceName != null && settings.DistributorService.ServiceName.Length > 0) { this.serviceName = settings.DistributorService.ServiceName; } } }
public void TestLoggingConfigurationView() { LoggingSettings loggingSettings = new LoggingSettings(); LoggingConfigurationView loggingConfigView = new LoggingConfigurationView(loggingSettings); loggingConfigView.ConfigureEventLogTraceListener("VALERYM-BTS2010", "MyLog", "MySource"); loggingConfigView.ConfigureRollingFlatFileTraceListener("MyLog.log", 5, 1000000); loggingConfigView.ConfigureEmailTraceListenerSmtpServer("exchangebox", 50, "smtpuser", "smtpsecret", false); loggingConfigView.ConfigureEmailTraceListener("*****@*****.**", "*****@*****.**"); loggingConfigView.ConfigureDatabaseTraceListener("MyLoggingDB"); loggingConfigView.AddTraceListener(typeof(FormattedEtwTraceListener)); loggingConfigView.EnableListenerForEventCategory(LoggingConfigurationView.FormattedDebugTraceListenerName, "ApplicationError", SourceLevels.All); StringWriter sw = new StringWriter(); XmlTextWriter xmlWriter = new XmlTextWriter(sw); loggingSettings.WriteXml(xmlWriter); string configSectionText = sw.GetStringBuilder().ToString(); Assert.IsTrue(configSectionText.Length > 0); /* * IConfigurationSource configSource = ConfigurationSourceFactory.Create(); * LoggingSettings loggingConfig = configSource.GetSection(LoggingSettings.SectionName) as LoggingSettings; * * LoggingConfigurationView loggingConfigView = new LoggingConfigurationView(loggingConfig); * * loggingConfigView.ConfigureEventLogTraceListener(".", "Application", ConfigurationManager.AppSettings["EvtSource"]); * loggingConfigView.ConfigureRollingFlatFileTraceListener(ConfigurationManager.AppSettings["LogFileName"], 5, 1000000); * loggingConfigView.AddTraceListener("EtwTraceListener", typeof(FormattedEtwTraceListener)); * * loggingConfigView.EnableListenerForEventCategory("EtwTraceListener", "ApplicationErrors", SourceLevels.All); * */ }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationTraceLogger"/> class. /// </summary> /// <param name="loggingConfigurationView">The <see cref="LoggingConfigurationView"/> to query for the configuration data.</param> public ConfigurationTraceLogger(LoggingConfigurationView loggingConfigurationView) { ArgumentValidation.CheckForNullReference(loggingConfigurationView, "loggingConfigurationView"); this.loggingConfigurationView = loggingConfigurationView; }
/// <summary> /// Initializes a new instance of <see cref="LogDistributor"></see> /// </summary> /// <param name="configurationContext"><see cref="ConfigurationContext"></see> used to initialize this instance</param> public LogDistributor(ConfigurationContext configurationContext) { this.loggingConfigurationView = new LoggingConfigurationView(configurationContext); this.events = new DistributorEvents(); this.defaulLogSink = new DefaultLogDestination(); }
private void RegisterFilters(LoggingConfigurationView loggingConfigurationView) { filters.Add("categoryFilter", new CategoryFilter(loggingConfigurationView)); filters.Add("priorityFilter", new PriorityFilter(loggingConfigurationView)); }
/// <summary> /// Initializes a new instance with configuration data. /// </summary> public CategoryFilter(LoggingConfigurationView loggingConfigurationView) { this.loggingConfigurationView = loggingConfigurationView; }
/// <summary> /// Initialize a new instance of a <see cref="LogFilter"/> class. Registers each ILogFilter. /// </summary> public LogFilter(LoggingConfigurationView loggingConfigurationView) { RegisterFilters(loggingConfigurationView); }
private string GetMsmqPath() { return(LoggingConfigurationView.GetDistributorSettings().DistributorService.MsmqPath); }
/// <summary> /// Create a new instance of a <see cref="PriorityFilter"/>. Reads the minimum priority /// from the configuration settings. /// </summary> public PriorityFilter(LoggingConfigurationView loggingConfigurationView) { this.loggingConfigurationView = loggingConfigurationView; }