Disha Shah's Blog

July 25, 2009

How to write error message to SharePoint logs file

SharePoint object model gives us very good functionality and ability to write our customize error messages into SharePoint logs file.

We can pass our error string into LogString method from Microsoft.Office.Server.Diagnostics.PortalLog class and it will write error into logs file.

Sample Code:

try

{

//CODE

}

catch (Exception Ex)
{
Microsoft.Office.Server.Diagnostics.PortalLog.LogString(“Exception – {0} – {1} – {2}” , “Sharepoint Application Name” , Ex.Message , Ex.StackTrace);

}

Catch the errors!!!

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.