Add logging to your SharePoint App

In this post I describe how to write information to the App Error Log.

Microsoft published an article about that: Adding troubleshooting instrumentation to an app for SharePoint. While figuring out the product GUID I found out that logging to the app log is easier that described in the article.

The following snipped describes in short what you have to do. There is no need to figure out the Product GUID.

var m_appContext = {...}; // Assign your context class instance here.

try {
   throw new Error("This is an error.");
catch (error) {
   SP.Utilities.Utility.logCustomAppError(m_appContext, error);
      function () { },
      function () { alert("Could not write to error log.") });

SharePoint dynamically generates a JavaScript “sp.debug.js” where the logCustomAppError method is encapsulated referencing the product GUID. You can check this out if you set a breakpoint in your project and step into the function call.

new SP.ClientActionInvokeStaticMethod(context, '{16f43e7e-bf35-475d-b677-9dc61e549339}', 'LogCustomAppError', [error]);

It takes a couple of minutes untill the entries apprear in the log. You can navigate to the log from your host web. First navigate to “Site Contents”.


Then klick on the dots “” of the app entry.


Now you can click on “Details” to navigate to the App Details page where you can see the Errors.


In my opinion, every app should make use of this.

2 Responses to “Add logging to your SharePoint App”

  1. Reblogged this on Share… What? and commented:
    Very nice intro to sp app logging

  2. Hi Alex, when referring to the Microsoft article, you’re mixing up “logCustomAppError” and “LogCustomRemoteAppError”. The logCustomAppError doesn’t take a productID (as you described) but is different from LogCustomRemoteAppError.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: