And we might need to write the exception/error details to log somewhere(list or text file in the file sytem).
As all the sharpoint error details are logged in 12 hive Log files, even we can write our custom error details to the same log file by using the ULS logging.
SPSecurity.RunWithElevatedPrivileges(delegate() { //Reference of Microsoft.Office.Server.dll needs to be added Microsoft.Office.Server.Diagnostics.PortalLog.LogString("My Custom Error - Message:{0} || Stack Trace:{1}", ex.Message, ex.StackTrace); });Note: the logging code statement should be run under RunWithElevatedPrivileges, if the code is executable by end user.
No comments:
Post a Comment