Reputation: 1337
I have a BaseActivity that I use as a parent for all my Activities. I'd like to log Activity events (onCreate(), onStart(), onResume(), etc.) to Crashlytics, so when a crash happens, I know what the user was doing and what Activities were currently alive. I added the following code to all the methods that I want to log:
CrashlyticsCore.getInstance().log(getClass().getSimpleName() + ".onResume()");
I'm wondering if it's a good idea to do it. Are the logs only sent when a crash happens? Will I not spam the server and produce unnecessary network calls for the users? Perhaps there's a better method of implementing bread crumbs with Crashlytics?
Upvotes: 3
Views: 3540
Reputation: 2814
As the name subtly suggests, Crashlytics will only trigger a report (and send a log) after a crash, and will only contain up to 64kb of log history as stated in the docs: "To make sure that sending crash reports has the smallest impact on your user’s devices, Crashlytics logs have a maximum size of 64 KB. When a log exceeds 64 KB, the earliest logged values will be dropped in order to maintain this threshold."
If you ask my personal opinion, it's not good practice or useful to log every onCreate
, onResume
. A Crashlytics report will already contain the stacktrace giving you insight on the error.
If you have caught exceptions and want to log those, you can do so as explain here, by calling Crashlytics.logException(e);
. Again only 8 of these will be stored: "For any individual app session, only the most recent 8 logged exceptions are stored".
Upvotes: 6