To enable logging in SharePoint 2013 app, use the following CSOM code.
try {
throw new Error("This is an App Error.");
}
catch (error) {
SP.Utilities.Utility.logCustomAppError(m_appContext, error);
m_appContext.executeQueryAsync(
function () { },
function () { alert("Could not write to error log.")
});