简体   繁体   中英

Implementing logging in SharePoint 2010 using the SharePoint Guidance library

I tried to use the SharePoint Guidance library and i got this error. Someone has a answer or propositions?

Thanks

Error is :
One or more error occurred while writing messages into the log.\r\nThe error while writing to the EventLog was:An exception has occurred.
    ExceptionType: 'LoggingException'
    ExceptionMessage: 'The Category 'Custom Error/DUET' was not found in the diagnostic categories collections.'
    StackTrace: '   at Microsoft.Practices.SharePoint.Common.Logging.DiagnosticsService.GetCategory(String categoryName)
           at Microsoft.Practices.SharePoint.Common.Logging.DiagnosticsService.LogTrace(String message, Int32 eventId, TraceSeverity severity, String categoryName)
           at Microsoft.Practices.SharePoint.Common.Logging.TraceLogger.Trace(String message, Int32 eventId, TraceSeverity severity, String category)
           at Microsoft.Practices.SharePoint.Common.Logging.SharePointLogger.WriteToDeveloperTrace(String message, Int32 eventId, TraceSeverity severity, String category)'
    Source: 'Microsoft.Practices.SharePoint.Common'
    TargetSite: 'Microsoft.SharePoint.Administration.SPDiagnosticsCategory GetCategory(System.String)'
\r\n Orginal logged message was: An error occurred while writing tot the Trace Log, trace message:kaka Error in Constant recovery
    ExceptionType: 'Exception'
    ExceptionMessage: 'testing sohail'
    StackTrace: ''
    Source: ''
    TargetSite: ''

What the others have said is correct. You will want to create and register your category when you deploy your code onto your sharepoint environment. I created my logging by doing the following:

  • I created a farm solution that would deploy all the logging logic on the farm
  • On the feature activation code, I checked to see if my logging category existed. If not, I create it
  • When I remove my solution, I deleted my custom category (this is optional)

Here's a link that describes how to created and register your category:

http://msmvps.com/blogs/sundar_narasiman/archive/2012/06/20/how-to-implement-logging-in-sharepoint-2010-part-2.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM