Tuesday, October 21, 2014

Logging error in event viewer

        void LogError(TraceSeverity Level, Exception exception)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                string errorMessage = exception.Message + "--" + exception.StackTrace;
                SPDiagnosticsService.Local.WriteTrace(0,
                    new SPDiagnosticsCategory("Error Log", Level, EventSeverity.Error), TraceSeverity.Unexpected, errorMessage, null);
            });
        }

No comments:

Post a Comment

How to launch a document by clicking a link to the file?

Word: <a href='ms-word:ofe|u|path/to/web/word/document.docx'>Link to document</a> Excel: <a href='ms-excel:o...