Exemplo n.º 1
0
        private void SendMessage(LogEntry logEntry)
        {
            ContextItems items = new ContextItems();

            items.ProcessContextItems(logEntry);
            LoggingSettings settings = loggingConfigurationView.GetLoggingSettings();
            LogDistributionStrategyFactory factory  = new LogDistributionStrategyFactory(this.loggingConfigurationView.ConfigurationContext);
            ILogDistributionStrategy       strategy = factory.CreateDistributionStrategy(settings.DistributionStrategy);

            strategy.SendLog(logEntry);
        }
        /// <summary>
        /// Adds a key/value pair to the <see cref="System.Runtime.Remoting.Messaging.CallContext"/> dictionary.
        /// Context items will be recorded with every log entry.
        /// </summary>
        /// <param name="key">Hashtable key</param>
        /// <param name="value">Value.  Objects will be serialized.</param>
        /// <example>The following example demonstrates use of the AddContextItem method.
        /// <code>Logger.SetContextItem("SessionID", myComponent.SessionId);</code></example>
        public void SetContextItem(object key, object value)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            ContextItems items = new ContextItems();

            items.SetContextItem(key, value);
        }
        private void ProcessLog(LogEntry log)
        {
            ContextItems items = new ContextItems();

            items.ProcessContextItems(log);

            IEnumerable <LogSource> matchingTraceSources = GetMatchingTraceSources(log);
            TraceListenerFilter     traceListenerFilter  = new TraceListenerFilter();

            foreach (LogSource traceSource in matchingTraceSources)
            {
                try
                {
                    traceSource.TraceData(log.Severity, log.EventId, log, traceListenerFilter);
                }
                catch (Exception ex)
                {
                    ReportExceptionDuringTracing(ex, log, traceSource);
                }
            }
        }
Exemplo n.º 4
0
        void ProcessLog(LogEntry log)
        {
            // revert any outstanding impersonation
            using (WindowsImpersonationContext revertImpersonationContext = RevertExistingImpersonation())
            {
                ContextItems items = new ContextItems();
                items.ProcessContextItems(log);

                IEnumerable <LogSource> matchingTraceSources = GetMatchingTraceSources(log);
                TraceListenerFilter     traceListenerFilter  = new TraceListenerFilter();

                foreach (LogSource traceSource in matchingTraceSources)
                {
                    try
                    {
                        traceSource.TraceData(log.Severity, log.EventId, log, traceListenerFilter);
                    }
                    catch (Exception ex)
                    {
                        ReportExceptionDuringTracing(ex, log, traceSource);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void ProcessLog(LogEntry log, TraceEventCache traceEventCache)
        {
            // revert any outstanding impersonation
            using (RevertExistingImpersonation())
            {
                var items = new ContextItems();
                items.ProcessContextItems(log);

                var matchingTraceSources = GetMatchingTraceSources(log);
                var traceListenerFilter  = new TraceListenerFilter();

                foreach (LogSource traceSource in matchingTraceSources)
                {
                    try
                    {
                        traceSource.TraceData(log.Severity, log.EventId, log, traceListenerFilter, traceEventCache);
                    }
                    catch (Exception ex)
                    {
                        ReportExceptionDuringTracing(ex, log, traceSource);
                    }
                }
            }
        }
        /// <summary>
        /// Empties the context items dictionary.
        /// </summary>
        public void FlushContextItems()
        {
            ContextItems items = new ContextItems();

            items.FlushContextItems();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Add a key/value pair to the <see cref="System.Runtime.Remoting.Messaging.CallContext"/> dictionary.  
        /// Context items will be recorded with every log entry.
        /// </summary>
        /// <param name="key">Hashtable key</param>
        /// <param name="value">Value.  Objects will be serialized.</param>
        /// <example>The following example demonstrates use of the AddContextItem method.
        /// <code>Logger.SetContextItem("SessionID", myComponent.SessionId);</code></example>
        public void SetContextItem(object key, object value)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            ContextItems items = new ContextItems();
            items.SetContextItem(key, value);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Empty the context items dictionary.
 /// </summary>
 public void FlushContextItems()
 {
     ContextItems items = new ContextItems();
     items.FlushContextItems();
 }
Exemplo n.º 9
0
 private void SendMessage(LogEntry logEntry)
 {
     ContextItems items = new ContextItems();
     items.ProcessContextItems(logEntry);
     LoggingSettings settings = loggingConfigurationView.GetLoggingSettings();
     LogDistributionStrategyFactory factory = new LogDistributionStrategyFactory(this.loggingConfigurationView.ConfigurationContext);
     ILogDistributionStrategy strategy = factory.CreateDistributionStrategy(settings.DistributionStrategy);
     strategy.SendLog(logEntry);
 }