Beispiel #1
0
        public void Startup(AppDomain appDomain)
        {
            Log.Info(typeof(ExceptionlessClient), "Client startup.");

            try {
                appDomain.UnhandledException -= OnAppDomainUnhandledException;
                appDomain.UnhandledException += OnAppDomainUnhandledException;
#if !PFX_LEGACY_3_5
                TaskScheduler.UnobservedTaskException -= TaskSchedulerOnUnobservedTaskException;
                TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
#endif
            } catch (Exception ex) {
                Log.Error(typeof(ExceptionlessClient), ex, "An error occurred while wiring up to the unhandled exception events. This will happen when you are not running under full trust.");
            }

            if (!Configuration.HasValidApiKey)
            {
                Log.Error(typeof(ExceptionlessClient), "Invalid Exceptionless API key. Please ensure that your API key is configured properly.");
            }

            Log.Info(typeof(ExceptionlessClient), "Triggering configuration update and queue processing...");

            UpdateConfigurationAsync();
            ProcessQueueAsync(1000);

            Log.Info(typeof(ExceptionlessClient), "Done triggering configuration update and queue processing.");

#if !SILVERLIGHT
            if (Configuration.TraceLogLimit > 0)
            {
                if (_traceListener != null && Trace.Listeners.Contains(_traceListener))
                {
                    Trace.Listeners.Remove(_traceListener);
                }

                _traceListener = new ExceptionlessTraceListener(Configuration.TraceLogLimit);
                Trace.Listeners.Add(_traceListener);
            }
#endif

            if (!_startupCalled)
            {
                LocalConfiguration.StartCount++;
                // TODO: This can be removed once we fix the bug in the ObservableConcurrentDictionary where IsDirty is not set immediately.
                LocalConfiguration.IsDirty = true;
                LocalConfiguration.Save();
            }

            _startupCalled = true;

            Log.Info(typeof(ExceptionlessClient), "Startup done.");
        }
Beispiel #2
0
        /// <summary>
        /// Adds the trace info as extended data to the event.
        /// </summary>
        /// <param name="ev">The event model.</param>
        /// <param name="listener">The listener.</param>
        /// <param name="maxEntriesToInclude"></param>
        public static void AddRecentTraceLogEntries(Event ev, ExceptionlessTraceListener listener = null, int maxEntriesToInclude = DefaultMaxEntriesToInclude)
        {
            if (ev.Data.ContainsKey(Event.KnownDataKeys.TraceLog))
            {
                return;
            }

            listener = listener ?? Trace.Listeners.OfType <ExceptionlessTraceListener>().FirstOrDefault();
            if (listener == null)
            {
                return;
            }

            List <string> logEntries = listener.GetLogEntries(maxEntriesToInclude);

            if (logEntries.Count > 0)
            {
                ev.Data.Add(Event.KnownDataKeys.TraceLog, logEntries);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Adds the trace info as extended data to the error.
        /// </summary>
        /// <param name="error">The error model.</param>
        public static void AddRecentTraceLogEntries(this Error error)
        {
            if (error.ExtendedData.ContainsKey(ExtendedDataDictionary.TRACE_LOG_KEY))
            {
                return;
            }

            ExceptionlessTraceListener traceListener = Trace.Listeners
                                                       .OfType <ExceptionlessTraceListener>()
                                                       .FirstOrDefault();

            if (traceListener == null)
            {
                return;
            }

            List <string> logEntries = traceListener.GetLogEntries();

            if (logEntries.Count > 0)
            {
                error.ExtendedData.Add(ExtendedDataDictionary.TRACE_LOG_KEY, traceListener.GetLogEntries());
            }
        }
Beispiel #4
0
 public TraceLogEnrichment(ExceptionlessConfiguration config, ExceptionlessTraceListener listener = null)
 {
     _configuration = config;
     _configuration.Settings.Changed += OnSettingsChanged;
     _listener = listener ?? Trace.Listeners.OfType <ExceptionlessTraceListener>().FirstOrDefault();
 }
        public void Startup(AppDomain appDomain) {
            Log.Info(typeof(ExceptionlessClient), "Client startup.");

            try {
                appDomain.UnhandledException -= OnAppDomainUnhandledException;
                appDomain.UnhandledException += OnAppDomainUnhandledException;
#if !PFX_LEGACY_3_5
                TaskScheduler.UnobservedTaskException -= TaskSchedulerOnUnobservedTaskException;
                TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
#endif
            } catch (Exception ex) {
                Log.Error(typeof(ExceptionlessClient), ex, "An error occurred while wiring up to the unhandled exception events. This will happen when you are not running under full trust.");
            }

            if (!Configuration.HasValidApiKey)
                Log.Error(typeof(ExceptionlessClient), "Invalid Exceptionless API key. Please ensure that your API key is configured properly.");

            Log.Info(typeof(ExceptionlessClient), "Triggering configuration update and queue processing...");

            UpdateConfigurationAsync();
            ProcessQueueAsync(1000);

            Log.Info(typeof(ExceptionlessClient), "Done triggering configuration update and queue processing.");

#if !SILVERLIGHT
            if (Configuration.TraceLogLimit > 0) {
                if (_traceListener != null && Trace.Listeners.Contains(_traceListener))
                    Trace.Listeners.Remove(_traceListener);

                _traceListener = new ExceptionlessTraceListener(Configuration.TraceLogLimit);
                Trace.Listeners.Add(_traceListener);
            }
#endif

            if (!_startupCalled) {
                LocalConfiguration.StartCount++;
                // TODO: This can be removed once we fix the bug in the ObservableConcurrentDictionary where IsDirty is not set immediately.
                LocalConfiguration.IsDirty = true;
                LocalConfiguration.Save();
            }

            _startupCalled = true;

            Log.Info(typeof(ExceptionlessClient), "Startup done.");
        }
Beispiel #6
0
 /// <summary>
 /// Adds the recent trace log entries to the event.
 /// </summary>
 /// <param name="builder">The event builder object.</param>
 /// <param name="listener">The listener.</param>
 /// <param name="maxEntriesToInclude"></param>
 public static EventBuilder AddRecentTraceLogEntries(this EventBuilder builder, ExceptionlessTraceListener listener = null, int maxEntriesToInclude = TraceLogPlugin.DefaultMaxEntriesToInclude)
 {
     TraceLogPlugin.AddRecentTraceLogEntries(builder.Target, listener, maxEntriesToInclude);
     return(builder);
 }