C# SP2013:SPDIagnosticsServiceBase.GetLocal上的SPDuplicateObjectException

C# SP2013:SPDIagnosticsServiceBase.GetLocal上的SPDuplicateObjectException,c#,exception,sharepoint,sharepoint-2013,C#,Exception,Sharepoint,Sharepoint 2013,我在SharePoint 2013服务器场上创建了一个自定义诊断服务,扩展了SPDiagnosticsServiceBase类 using Microsoft.SharePoint.Administration; using System; using System.Collections.Generic; using System.ComponentModel; namespace Custom.Sharepoint.Services.Logging { [System.Runtim

我在SharePoint 2013服务器场上创建了一个自定义诊断服务,扩展了SPDiagnosticsServiceBase类

using Microsoft.SharePoint.Administration;
using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace Custom.Sharepoint.Services.Logging
{
    [System.Runtime.InteropServices.Guid("DBEEB5AB-C5A7-46B5-A2BB-5581F960C333")]
    public class CustomLoggingService : SPDiagnosticsServiceBase
    {
        public static string CustomLoggingServiceName = "Custom Logging Service";
        public static string CustomLoggingServiceTypeName = "Custom Logs";

        public enum CategoryId
        {
            General = 0,
            Base = 100,
            QA = 200,
            Admin = 300
        }

        public CustomLoggingService()
        {

        }

        public CustomLoggingService(string name, SPFarm farm) : base(CustomLoggingServiceName, farm)
        {

        }

        public static CustomLoggingService Local
        {
            get
            {
                return GetLocal<CustomLoggingService>();
            }
        }

        public override string DisplayName
        {
            get
            {
                return CustomLoggingServiceName;
            }
        }

        public override string TypeName
        {
            get
            {
                return CustomLoggingServiceTypeName;
            }
        }

        protected override IEnumerable<SPDiagnosticsArea> ProvideAreas()
        {
            List<SPDiagnosticsCategory> categories = new List<SPDiagnosticsCategory>();
            foreach (string catName in Enum.GetNames(typeof(CategoryId)))
            {
                uint catId = (uint)(int)Enum.Parse(typeof(CategoryId), catName);
                categories.Add(new SPDiagnosticsCategory(catName, TraceSeverity.Verbose, EventSeverity.Error, 0, catId));
            }

            yield return new SPDiagnosticsArea(CustomLoggingServiceName, categories);
        }
        public SPDiagnosticsCategory this[CategoryId id]
        {
            get
            {
                return Areas[CustomLoggingServiceName].Categories[id.ToString()];
            }
        }

        public static void LogError(CategoryId category, string errorMessage, TraceSeverity severity)
        {
            SPDiagnosticsCategory cat = Local.Areas[CustomLoggingServiceName].Categories[category.ToString()];
            Local.WriteTrace(0, cat, severity, errorMessage);
        }
    }
}
谢谢

CustomLoggingService.LogError(CustomLoggingService.CategoryId.QA, "Message from the QA Solution in the ULS", TraceSeverity.High);