Exception logging in Office 365 - SharePoint Online custom solutions

Normally we use various logging options in SharePoint custom development, like writing to event log, ULS log, writing to developer dashboard, some use enterprise library logging block to write log to database as well. We don't have this freedom when developing sandbox solutions. Even in this case we can create full trust proxy to write logs to ULS and try to consume that in our sandbox solution. This works fine for the sandbox solutions which are deployed to the on premise environments, but in case of SharePoint online i.e. Office 365 we don't have privileges to view the ULS logs. 
How can we write the exception messages which can help us in debugging or troubleshooting the issue. I'm trying list down few available options which came in my mind.

1.Writing the exceptions in the screen or throw the exception when raised
I won't favor this option, as part of good user experience we won't expect our end users to look into the exception message or nasty stack trace messages.

2. Write the exception as a comment using the literal.
When the exception is written as comment block it won't be visible naked eyes of the end user, developer can see the source code once the page is rendered in the browser. Use some specific keywords so the exception can be searched easily. The drawback with this option is its not possible to write to the literal as comment all the time. Like in scenario like writing event receiver or workflow you can't write everything to the UI.

3. Write the exception to custom list.
With this option you can write the exception to a custom list when occurred. I'm favor of this option. You can refer to custom list at any point of time and fully leverage the SharePoint capabilities. Like configuring alerts, workflows which can notify admin when any exception occurred.

I have tried to create a reusable exception logging for Office 365 Sandbox custom solutions, I have used the above said option.

How it works
Whenever any exception occurs in our custom solution, it can be written to the list in the SharePoint site itself. So I have created a content type which can cater different fields associated with the logs. A list instance will be created which will have the above content type associated. Use the Logger class method which has methods to write to the logs. Whenever there is need for any logging in the custom solution, make sure the feature is activated which will create list instance and use logger class methods and start logging.

  1. Download the Rjesh.Cloud.Exception.Logging WSP - sandbox solution from the below provided link
  2. Add the wsp to the site collection solutions
  3. Activate the solution
  4. Go to the site features and activate the feature <Rjesh.Cloud.Exception.Logging>
  5. Download the Logger.cs file from the below provided link
  6. Add the cs file to your solution where you want to use logging
  7. Add the namespace in your code
  8. Use the logging methods as described below in the snippet, you can use the overload methods based on you logging needs.
How to use logger