Tag Archives: SPDiagnosticsService

How to write messages to the SharePoint log

How to write to the SharePoint log. The top two rows are the imports you need.

using Microsoft.Office.Server.Diagnostics;
using Microsoft.SharePoint.Administration;

SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("MyCategory", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, "MyMessage", "MyStackTrace");
Advertisements