Error logging in SharePoint hosted app RRS feed

  • Question

  • Hi All,

    Is there any way I can log errors in App web list (Error list which I have created) in sharepoint hosted app or is there any standard practice which I can follow to log error in SharePoint hosted app. I want to log errors in list in app web.

    Thanks is advance...!!



    Wednesday, June 17, 2015 2:50 PM


  • You can use REST or JSOM to log to your error list. For example you can have a LogMessage field that holds multiple lines of text. And you could have a LogType field which would hold the type of log message, for example trace or error. Below is an example using REST:

    function logMessage(logType, logMessage) {
                var dfd = $.Deferred();
                var appweburl: string = _spPageContextInfo.webAbsoluteUrl
                    url: appweburl + "/_api/web/lists/getbytitle('ApplicationLog')/items",
                    type: "POST",
                    data: JSON.stringify({
                        '__metadata': { 'type': 'SP.Data.ApplicationLogListItem' }, 'LogType': logType, 'LogMessage': logMessage, 'LogDate': new Date(Date.now()).toISOString()
                    headers: {
                        "accept": "application/json;odata=verbose",
                        "content-type": "application/json;odata=verbose",
                        "X-RequestDigest": $("#__REQUESTDIGEST").val()
                    success: function (data) {
                    error: function (err) {
                return dfd;

    Blog | SharePoint Field Notes Dev Tools | SPFastDeploy | SPRemoteAPIExplorer

    Wednesday, June 17, 2015 7:16 PM