Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogWriterImpl"/> class.
 /// </summary>
 /// <param name="filters">The collection of filters to use when processing an entry.</param>
 /// <param name="traceSources">The trace sources to dispatch entries to.</param>
 /// <param name="allEventsTraceSource">The special <see cref="LogSource"/> to which all log entries should be logged.</param>
 /// <param name="notProcessedTraceSource">The special <see cref="LogSource"/> to which log entries with at least one non-matching category should be logged.</param>
 /// <param name="errorsTraceSource">The special <see cref="LogSource"/> to which internal errors must be logged.</param>
 /// <param name="defaultCategory">The default category to set when entry categories list of a log entry is empty.</param>
 /// <param name="tracingEnabled">The tracing status.</param>
 /// <param name="logWarningsWhenNoCategoriesMatch">true if warnings should be logged when a non-matching category is found.</param>
 /// <param name="revertImpersonation">true if impersonation should be reverted while logging.</param>
 /// <param name="instrumentationProvider">The instrumentation provider to use.</param>
 public LogWriterImpl(
     IEnumerable <ILogFilter> filters,
     IDictionary <string, LogSource> traceSources,
     LogSource allEventsTraceSource,
     LogSource notProcessedTraceSource,
     LogSource errorsTraceSource,
     string defaultCategory,
     bool tracingEnabled,
     bool logWarningsWhenNoCategoriesMatch,
     bool revertImpersonation,
     ILoggingInstrumentationProvider instrumentationProvider)
     : this(
         CreateStructureHolder(
             filters,
             traceSources,
             allEventsTraceSource,
             notProcessedTraceSource,
             errorsTraceSource,
             defaultCategory,
             tracingEnabled,
             logWarningsWhenNoCategoriesMatch,
             revertImpersonation),
         instrumentationProvider,
         new LoggingUpdateCoordinator(null))
 {
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogWriterImpl"/> class.
 /// </summary>
 /// <param name="filters">The collection of filters to use when processing an entry.</param>
 /// <param name="traceSources">The trace sources to dispatch entries to.</param>
 /// <param name="errorsTraceSource">The special <see cref="LogSource"/> to which internal errors must be logged.</param>
 /// <param name="defaultCategory">The default category to set when entry categories list is empty.</param>
 /// <param name="instrumentationProvider">The instrumentation provider to use.</param>
 public LogWriterImpl(IEnumerable <ILogFilter> filters,
                      IDictionary <string, LogSource> traceSources,
                      LogSource errorsTraceSource,
                      string defaultCategory,
                      ILoggingInstrumentationProvider instrumentationProvider)
     : this(filters, traceSources, null, null, errorsTraceSource, defaultCategory, false, false, true, instrumentationProvider)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="MessagingUpdateCoordinator"/> class with 
        /// a <see cref="ConfigurationChangeEventSource"/>.
        /// </summary>
        /// <remarks>
        /// The LoggingUpdateCoordinator attaches itself to the <see cref="ConfigurationChangeEventSource"/> events.
        /// </remarks>
        /// <param name="eventSource">The source for configuration change events.</param>
        /// <param name="instrumentationProvider">The <see cref="ILoggingInstrumentationProvider"/> to use for exception and instrumentation event notification.</param>
        public MessagingUpdateCoordinator(ConfigurationChangeEventSource eventSource,
            ILoggingInstrumentationProvider instrumentationProvider)
        {
            this.accessLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);

            this.eventSource = eventSource;
            this.instrumentationProvider = instrumentationProvider;
            if (this.eventSource != null)
            {
                this.eventSource.GetSection<MessagingSettings>().SectionChanged += OnConfigurationChanged;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LoggingUpdateCoordinator"/> class with
        /// a <see cref="ConfigurationChangeEventSource"/>.
        /// </summary>
        /// <remarks>
        /// The LoggingUpdateCoordinator attaches itself to the <see cref="ConfigurationChangeEventSource"/> events.
        /// </remarks>
        /// <param name="eventSource">The source for configuration change events.</param>
        /// <param name="instrumentationProvider">The <see cref="ILoggingInstrumentationProvider"/> to use for exception and instrumentation event notification.</param>
        public LoggingUpdateCoordinator(ConfigurationChangeEventSource eventSource,
                                        ILoggingInstrumentationProvider instrumentationProvider)
        {
            this.accessLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);

            this.eventSource             = eventSource;
            this.instrumentationProvider = instrumentationProvider;
            if (this.eventSource != null)
            {
                this.eventSource.GetSection <LoggingSettings>().SectionChanged += OnConfigurationChanged;
            }
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogSource"/> class with a name, a collection of <see cref="TraceListener"/>s, a level and the auto flush.
 /// </summary>
 /// <param name="name">The name for the instance.</param>
 /// <param name="traceListeners">The collection of <see cref="TraceListener"/>s.</param>
 /// <param name="level">The <see cref="SourceLevels"/> value.</param>
 /// <param name="autoFlush">If Flush should be called on the Listeners after every write.</param>
 /// <param name="instrumentationProvider">The instrumentation provider to use.</param>
 public LogSource(
     string name,
     IEnumerable <TraceListener> traceListeners,
     SourceLevels level,
     bool autoFlush,
     ILoggingInstrumentationProvider instrumentationProvider)
 {
     this.name                    = name;
     this.traceListeners          = new List <TraceListener>(traceListeners);
     this.level                   = level;
     this.instrumentationProvider = instrumentationProvider;
     this.autoFlush               = autoFlush;
 }
Beispiel #6
0
        public void SetUp()
        {
            nameFormatter                    = new AppDomainNameFormatter(applicationInstanceName);
            instrumentationProvider          = new LoggingInstrumentationProvider(instanceName, true, true, applicationInstanceName);
            tracerInstrumentationProvider    = new TracerInstrumentationProvider(true, false, string.Empty);
            formattedInstanceName            = nameFormatter.CreateName(instanceName);
            totalLoggingEventsRaised         = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalLoggingEventsRaised, formattedInstanceName);
            totalTraceListenerEntriesWritten = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalTraceListenerEntriesWritten, formattedInstanceName);

            // Use AppDomainFriendlyName for the instance name
            nameFormatter         = new AppDomainNameFormatter();
            formattedInstanceName = nameFormatter.CreateName(instanceName);

            totalTraceOperationsStartedCounter = new EnterpriseLibraryPerformanceCounter(TracerInstrumentationProvider.counterCategoryName, TracerInstrumentationProvider.TotalTraceOperationsStartedCounterName, formattedInstanceName);
        }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LogWriterImpl"/> class.
        /// </summary>
        /// <param name="structureHolder">The initial implementation of the logging stack</param>
        /// <param name="instrumentationProvider">The instrumentation provider to use.</param>
        /// <param name="updateCoordinator">The coordinator for logging operations.</param>
        public LogWriterImpl(
            LogWriterStructureHolder structureHolder,
            ILoggingInstrumentationProvider instrumentationProvider,
            ILoggingUpdateCoordinator updateCoordinator)
        {
            Guard.ArgumentNotNull(structureHolder, "structureHolder");
            Guard.ArgumentNotNull(instrumentationProvider, "instrumentationProvider");
            Guard.ArgumentNotNull(updateCoordinator, "updateCoordinator");

            this.instrumentationProvider = instrumentationProvider;
            this.ReplaceStructureHolder(structureHolder);

            this.updateCoordinator = updateCoordinator;
            this.updateCoordinator.RegisterLoggingUpdateHandler(this);
        }
        public void SetUp()
        {
            nameFormatter = new AppDomainNameFormatter(applicationInstanceName);
            instrumentationProvider = new LoggingInstrumentationProvider(instanceName, true, true, applicationInstanceName);
            tracerInstrumentationProvider = new TracerInstrumentationProvider(true, false, string.Empty);
            formattedInstanceName = nameFormatter.CreateName(instanceName);
            totalLoggingEventsRaised = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalLoggingEventsRaised, formattedInstanceName);
            totalTraceListenerEntriesWritten = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalTraceListenerEntriesWritten, formattedInstanceName);

            // Use AppDomainFriendlyName for the instance name
            nameFormatter = new AppDomainNameFormatter();
            formattedInstanceName = nameFormatter.CreateName(instanceName);

            totalTraceOperationsStartedCounter = new EnterpriseLibraryPerformanceCounter(TracerInstrumentationProvider.counterCategoryName, TracerInstrumentationProvider.TotalTraceOperationsStartedCounterName, formattedInstanceName);
        }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogWriterImpl"/> class.
 /// </summary>
 /// <param name="filters">The collection of filters to use when processing an entry.</param>
 /// <param name="traceSources">The trace sources to dispatch entries to.</param>
 /// <param name="allEventsTraceSource">The special <see cref="LogSource"/> to which all log entries should be logged.</param>
 /// <param name="notProcessedTraceSource">The special <see cref="LogSource"/> to which log entries with at least one non-matching category should be logged.</param>
 /// <param name="errorsTraceSource">The special <see cref="LogSource"/> to which internal errors must be logged.</param>
 /// <param name="defaultCategory">The default category to set when entry categories list is empty.</param>
 /// <param name="tracingEnabled">The tracing status.</param>
 /// <param name="logWarningsWhenNoCategoriesMatch">true if warnings should be logged when a non-matching category is found.</param>
 /// <param name="instrumentationProvider">The instrumentation provider to use.</param>
 public LogWriterImpl(IEnumerable <ILogFilter> filters,
                      IEnumerable <LogSource> traceSources,
                      LogSource allEventsTraceSource,
                      LogSource notProcessedTraceSource,
                      LogSource errorsTraceSource,
                      string defaultCategory,
                      bool tracingEnabled,
                      bool logWarningsWhenNoCategoriesMatch,
                      ILoggingInstrumentationProvider instrumentationProvider)
     : this(filters,
            CreateTraceSourcesDictionary(traceSources),
            allEventsTraceSource,
            notProcessedTraceSource,
            errorsTraceSource,
            defaultCategory,
            tracingEnabled,
            logWarningsWhenNoCategoriesMatch,
            true,
            instrumentationProvider)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LogSource"/> class with a name, a collection of <see cref="TraceListener"/>s, a level and the auto flush.
 /// </summary>
 /// <param name="name">The name for the instance.</param>
 /// <param name="traceListeners">The collection of <see cref="TraceListener"/>s.</param>
 /// <param name="level">The <see cref="SourceLevels"/> value.</param>
 /// <param name="autoFlush">If Flush should be called on the Listeners after every write.</param>
 /// <param name="instrumentationProvider">The instrumentation provider to use.</param>
 public LogSource(
     string name, 
     IEnumerable<TraceListener> traceListeners, 
     SourceLevels level, 
     bool autoFlush, 
     ILoggingInstrumentationProvider instrumentationProvider)
 {
     this.name = name;
     this.traceListeners = new List<TraceListener>(traceListeners);
     this.level = level;
     this.instrumentationProvider = instrumentationProvider;
     this.autoFlush = autoFlush;
 }