Example #1
0
        protected override Type GetConfigurationType(string formatterName)
        {
            LoggingConfigurationView loggingConfigurationView = (LoggingConfigurationView)CreateConfigurationView();
            FormatterData            data = loggingConfigurationView.GetFormatterData(formatterName);

            return(GetType(data.TypeName));
        }
Example #2
0
        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));
        }
Example #4
0
        /// <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;
        }
Example #5
0
        /// <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;
        }
Example #6
0
        /// <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;
        }
Example #7
0
        /// <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();
        }
Example #8
0
        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);
        }
Example #9
0
        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;
                }
            }
        }
Example #10
0
        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);
             * */
        }
Example #11
0
 /// <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 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;
 }
Example #13
0
 /// <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();
 }
Example #14
0
 private void RegisterFilters(LoggingConfigurationView loggingConfigurationView)
 {
     filters.Add("categoryFilter", new CategoryFilter(loggingConfigurationView));
     filters.Add("priorityFilter", new PriorityFilter(loggingConfigurationView));
 }
Example #15
0
 /// <summary>
 /// Initializes a new instance with configuration data.
 /// </summary>
 public CategoryFilter(LoggingConfigurationView loggingConfigurationView)
 {
     this.loggingConfigurationView = loggingConfigurationView;
 }
Example #16
0
        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;
                }
            }
        }
Example #17
0
 /// <summary>
 /// Initialize a new instance of a <see cref="LogFilter"/> class.  Registers each ILogFilter.
 /// </summary>
 public LogFilter(LoggingConfigurationView loggingConfigurationView)
 {
     RegisterFilters(loggingConfigurationView);
 }
Example #18
0
 private string GetMsmqPath()
 {
     return(LoggingConfigurationView.GetDistributorSettings().DistributorService.MsmqPath);
 }
Example #19
0
 /// <summary>
 /// Initialize a new instance of a <see cref="LogFilter"/> class.  Registers each ILogFilter.
 /// </summary>
 public LogFilter(LoggingConfigurationView loggingConfigurationView)
 {
     RegisterFilters(loggingConfigurationView);
 }
Example #20
0
 /// <summary>
 /// Initializes a new instance with configuration data.
 /// </summary>
 public CategoryFilter(LoggingConfigurationView loggingConfigurationView)
 {
     this.loggingConfigurationView = loggingConfigurationView;
 }
Example #21
0
 private void RegisterFilters(LoggingConfigurationView loggingConfigurationView)
 {
     filters.Add("categoryFilter", new CategoryFilter(loggingConfigurationView));
     filters.Add("priorityFilter", new PriorityFilter(loggingConfigurationView));
 }
Example #22
0
 /// <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;
 }
Example #23
0
 /// <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();
 }
Example #24
0
 /// <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;
 }