title: Logging Xamarin unhandled (Android uncaught) exceptions
body: <p>I'd like to log unhandled exceptions, but I am seeing conflicting information on if and how this may be possible.</p>
  
  <p>I understand that Xamarin raises an <code>AndroidEnvironment.UnhandledExceptionRaiser</code> or <code>AppDomain.CurrentDomain.UnhandledException</code> event and that I can subscribe to this event, but I am under the impression that Android is killing my process and that I don't have access to Android.Utils.Log or the file system.</p>
  
  <p>If you take a look at Xamarin's <a href="https://github.com/xamarin/monodroid-samples/blob/master/AdvancedAppLifecycleDemos/HandlingCrashes/App.cs" rel="noreferrer">AdvancedAppLifecycleDemos/HandlingCrashes/App.cs</a> there's a compelling argument that you can't log this exception. </p>
  
  <pre><code>    /// &lt;summary&gt;
      /// When app-wide unhandled exceptions are hit, this will handle them. Be aware however, that typically
      /// android will be destroying the process, so there's not a lot you can do on the android side of things,
      /// but your xamarin code should still be able to work. so if you have a custom err logging manager or 
      /// something, you can call that here. You _won't_ be able to call Android.Util.Log, because Dalvik
      /// will destroy the java side of the process.
      /// &lt;/summary&gt;
      protected void HandleUnhandledException(object sender, UnhandledExceptionEventArgs args)
      {
          Exception e = (Exception)args.ExceptionObject;
  
          // log won't be available, because dalvik is destroying the process
          //Log.Debug (logTag, "MyHandler caught : " + e.Message);
          // instead, your err handling code shoudl be run:
          Console.WriteLine("========= MyHandler caught : " + e.Message);
      }
  </code></pre>
  
  <p>So how can an unhandled exception be logged?</p>