Brad's profileBrad Younge's BlogBlogLists Tools Help

Blog


    9/10/2007

    Logging Errors in SharePoint 2007

    Quick post here… I had the need to log to the SharePoint log files found at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS and had a hard time finding the 1 line of code to do it, so I thought I'd blog about it really quick. If you have this need, use something like the following line of code:

    catch(Exception myException)
    {
    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("Exception Occurred: {0} || {1}", myException.Message, myException.StackTrace);
    }

    Hope this saves someone out there a bit of time searching for this…