5

I have Crashlytics properly configured in my app. I can see crash reports.

I tried to add a custom log to the crash reports but I do not see anything in the report. I tried to move the log out of the uncaughtException handler and in that case I see the logs.

So if I log while the application is running properly then I see the logs in the crash report when the application crashes but if I try to add a log in my uncaughtException handler these logs are not shown.

is this the proper behaviour?

I'm on Android.

To log I just use:

    Crashlytics.log(myLog);

myLog is a non-null non-empty string (I checked it)

kingston
  • 11,053
  • 14
  • 62
  • 116
  • Could you paste your whole uncaught exception handler ? My understanding is that Crashlytics should be doing it itself by default though, so it may be good if you could paste your Crashlytics setting code too. – desseim Jan 27 '14 at 10:05
  • Similar to: http://stackoverflow.com/questions/24336444/trouble-with-logging-my-data-with-crashlytics – saltandpepper Jul 14 '16 at 12:51

2 Answers2

4

You are right you need to move the Crashlitycs.start before registering your uncaughtException handler.

  • This is correct - add your handler *afterwards* so it can receive the call before than the default handler for Crashlytics. It seems that (at least in v1.1.10) that the log messages are being handled asynchronously in Crashlytics, so you may need to `Thread.sleep()` for 1-2 seconds before handing the exception to the Crashlytics `UncaughtExceptionHandler` – Andrew Alcock Mar 25 '14 at 08:09
  • Can anyone further elaborate on this? I have Crashlytics logging some debug values and it's showing in the logcat, but it never gets sent with the crash reports. The debug logs are dispersed everywhere so I'm sure some should be stored before the crash, and it doesn't send with both uncaught exceptions and non-fatal exceptions – Allan W Jul 17 '17 at 06:32
2

I thought that an explanation could be that the logs are sent to the server asynchronously and if the application gets killed before they are sent you don't see them in the crash report. I checked and that is not the case: even if you wait for a while before calling the default handler nothing happen.

The only explanation for now is that Crashlitycs uncaughtException handler is called before mine.

So to fix the issue it is enough to register the handler after calling Crashlytics.start

kingston
  • 11,053
  • 14
  • 62
  • 116