SharePoint online has really limited availability for error logging built in. Most of the time you have to throw the exception to either standard output, a list, or if it is a provider hosted application using a local text file. None of these options is terrible attractive since SharePoint already has logging availability in the ULS and a lot of fancy tools that allow relevant parsing to occur.
Using the ULS off premise isn’t really as easier as it is on premise (shocker). To do it, firstly, you have to make the relevant service reference. This is located here:
Once you have that, if you are deploying a generic service application remember to go to your settings page and add some logic in order to look up the current URL using a dynamic reference. If not, then you are almost there, it is helpful to push this logic to some sort of static method if you are using it for broad scope exception handling, but the meat is in the SendClientScriptErrorReport method. You can find this off the diagnostic object, this will depend on how you qualify it however (i.e. a top level alias directive). The method itself will take the form:
proxy.SendClientScriptErrorReport(“message”, “filename”, “line number”, “client”, “stack”, “team”, “filename);