使用SharePoint Guidance库在SharePoint 2010中实现日志记录

时间:2013-03-06 10:27:31

标签: sharepoint sharepoint-2010

我尝试使用SharePoint Guidance库,但是我遇到了这个错误。 有人有答案或主张吗?

由于

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: ''

1 个答案:

答案 0 :(得分:1)

其他人所说的是正确的。将代码部署到sharepoint环境时,您需要创建并注册类别。我通过执行以下操作创建了日志记录:

  • 我创建了一个可以部署服务器场上所有日志记录逻辑的服务器场解决方案
  • 在功能激活码上,我检查了我的记录类别是否存在。如果没有,我创建它
  • 当我删除我的解决方案时,我删除了我的自定义类别(这是可选的)

这是一个描述如何创建和注册您的类别的链接:

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