public static void EnsureConfiguredAreasRegistered()
        {
            var mgr   = SharePointServiceLocator.GetCurrent().GetInstance <IConfigManager>();
            var areas = new DiagnosticsAreaCollection(mgr);

            RegisterAreas(areas);
        }
        public static void RegisterAreas(DiagnosticsAreaCollection areas)
        {
            Validation.ArgumentNotNull(areas, "areas");

            foreach (DiagnosticsArea area in areas)
            {
                if (!EventLog.SourceExists(area.Name))
                {
                    EventLog.CreateEventSource(area.Name, Constants.EventLogName);
                }
            }

            if (!EventLog.SourceExists(DiagnosticsArea.DefaultSPDiagnosticsArea.Name))
            {
                EventLog.CreateEventSource(DiagnosticsArea.DefaultSPDiagnosticsArea.Name, Constants.EventLogName);
            }
        }
Esempio n. 3
0
        protected override IEnumerable <SPDiagnosticsArea> ProvideAreas()
        {
            IConfigManager config = SharePointServiceLocator.GetCurrent().GetInstance <IConfigManager>();

            IEnumerable <DiagnosticsArea> diagnosticsAreas = new DiagnosticsAreaCollection(config);

            List <SPDiagnosticsArea> spAreas = new List <SPDiagnosticsArea>();

            foreach (DiagnosticsArea area in diagnosticsAreas)
            {
                List <SPDiagnosticsCategory> spCategories = new List <SPDiagnosticsCategory>();
                foreach (DiagnosticsCategory category in area.DiagnosticsCategories)
                {
                    spCategories.Add(category.ToSPDiagnosticsCategory());
                }
                SPDiagnosticsArea spArea = new SPDiagnosticsArea(area.Name, spCategories);
                spAreas.Add(spArea);
            }

            spAreas.Add(DiagnosticsArea.DefaultSPDiagnosticsArea);

            return(spAreas);
        }