Enhance Crash Reports

At times, even full stack traces with line numbers aren’t quite enough to pinpoint the bug. To give you even more insight, Crashlytics provides 4 logging mechanisms right out of the box: logging, custom keys, user information, and caught exceptions (see the Caught Exceptions page).

Note

If you are using CrashlyticsCore instead of Crashlytics, then you’ll use its instance below. For example: CrashlyticsCore.getInstance().log.

Custom Logging

Logged messages are associated with your crash data and are visible in the Crashlytics dashboard if you look at the specific crash itself.

We’ve built Crashlytics.log to help pinpoint issues. The recommended way to add custom logging to your app is:

Crashlytics.log(int priority, String tag, String msg);

In addition to writing to the next crash report, it will also write to the LogCat using android.util.Log.println(priority, tag, msg). If you don’t want to write to LogCat you should call:

Crashlytics.log(msg);

which will only write to the Crashlytics crash report, e.g.:

Crashlytics.log("Higgs-Boson detected! Bailing out...");

Note

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.

Custom Keys

Crashlytics allows you to associate arbitrary key/value pairs with your crash reports, which are viewable right from the Crashlytics dashboard. Setting keys are as easy as calling: Crashlytics.setString(key, value) or one of the related methods. Options are:

void setBool(String key, boolean value);

void setDouble(String key, double value);

void setFloat(String key, float value);

void setInt(String key, int value);

Re-setting the same key will update the value. Examples:

Crashlytics.setInt("current_level", 3);
Crashlytics.setString("last_UI_action", "logged_in");

Note

Crashlytics supports a maximum of 64 key/value pairs. Once you reach this threshold, additional values are not saved. Each key/value pair can be up to 1 KB in size.

User Information

You can use Crashlytics.setUserIdentifier to provide an ID number, token, or hashed value that uniquely identifies the end-user of your application without disclosing or transmitting any of their personal information. This value is displayed right in the Fabric dashboard.

void Crashlytics.setUserIdentifier(String identifier);

If you would like to take advantage of advanced user identifier features, you can additionally use both:

void Crashlytics.setUserName(String name);
void Crashlytics.setUserEmail(String email);