How to Use a SharePoint List to Log Application Errors

March 18, 2011 by
Filed under: Logging 

Occasionally, as a developer, you will not have access to the SharePoint log that is maintained within the file system. One way to get around this limitation is to make use of a SharePoint list as a location for logging application errors. This list can easily be created at the site collection root and then given very limited access for viewing. Here’s how it’s done…

Create a list using the following specifications:

Name – “Application Log”

        Title (Single line of text) (Required)
        Message (Single line of text) (Required)
        StackTrace (Multiple lines of text) (Required)
        User (Single line of text) (Required)
        Date (Date/Time) (Required)

In your custom code add a try/catch statement and call the error handler. You may optionally pass in a note specific to that error.

Add the following class to your solution.

I hope someone finds this useful.


Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

You must be logged in to post a comment.