SharePoint exceptions are derived from the SPException class.
Below code gives you example for write error logging details to the SharePoint Unified Logging Service (ULS) logs.
void ErrorEntry()
{
try
{
//Development code
}
catch (Exception ex)
{
SPDiagnosticsCategory diagnosticsCat = new SPDiagnosticsCategory("categoryName" , TraceSeverity.Monitorable ,EventSeverity.Error);
SPDiagnosticsService.Local.WriteEvent(1 , diagnosticsCat , EventSeverity.Error , "Error Message" , ex.StackTrace);
}
}
Below code gives you example for write error logging details to the SharePoint Unified Logging Service (ULS) logs.
void ErrorEntry()
{
try
{
//Development code
}
catch (Exception ex)
{
SPDiagnosticsCategory diagnosticsCat = new SPDiagnosticsCategory("categoryName" , TraceSeverity.Monitorable ,EventSeverity.Error);
SPDiagnosticsService.Local.WriteEvent(1 , diagnosticsCat , EventSeverity.Error , "Error Message" , ex.StackTrace);
}
}
No comments:
Post a Comment