Monday, December 13, 2010

Logging error message in SharePoint Programmatically

To log an error message from your custom code, first you need to take reference of 
"Microsoft.Office.Server.dll". From this dll we will use the diagnostics features.


Namespace:
Microsoft.Office.Server.Diagnostics


Next, following method need to be used for logging a message in SharePoint Log.



         private void LogULS()
        {
            PortalLog.LogString("A test Error Message.");
        }


The log can be access from 
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS" directory.