HomeDocumentationAPI Reference
Getting StartedAPI ReferenceBug ReportingCrash ReportingAPMHelp Center
These docs are for v8.1. Click to read the latest docs for v12.0.0.

Report Logs

This section covers how Instabug automatically attaches the console logs, the verbose logs, all the steps done by the user until a bug report is sent.

🚧

Privacy Policy

It is highly recommended to mention in your privacy policy that you may be collecting logging data in order to assist troubleshooting bugs.

A variety of logs types are sent with each bug report. They will appear within each report on your Instabug dashboard as shown below. The cut-off point of the log collection is when Instabug is shown. We support the following types of logs:

2169

Logs - Dashboard

User Steps

Instabug can detect user steps that can help you regenerate a bug in your app. To Allow or disallow Instabug to record user steps, you need to call the following method.

//iOS
Instabug.TrackUserSteps = true;

//Android
new Instabug.Builder(this, "ANDROID_APP_TOKEN")
            .SetInvocationEvent(InstabugInvocationEvent.Shake)
            .SetTrackingUserStepsState(Feature.State.Disabled)
						.Build();

Repro Steps

The set of steps that the user commits while they are in a specific view are grouped together. When the user navigates to a new view, this action is reflected in the repro steps and all the interactions happening within the new view are grouped together until the user navigates away from this view.

This feature is enabled by default starting from the Silver Plan. You can control it through the following API.

//iOS
Instabug.ReproStepsMode = IBGUserStepsMode.Enabled;

//Android 
new Instabug.Builder(this, "ANDROID_APP_TOKEN")
            .SetInvocationEvent(InstabugInvocationEvent.Shake)
            .SetReproStepsState(State.Enabled)
						.Build();

Here are the possible arguments.

//iOS
IBGUserStepsMode.Enabled
IBGUserStepsMode.Disabled
  
//Android
State.Enabled
State.Disabled

Network Logs

🚧

Supported on Android only

The network logs are currently supported on Android only.

Instabug offers logging for all network requests performed by your app. Requests details, along with their responses, are going to be sent with each report. Instabug will also show an alert in the bug report when it finds that some network requests have timed-out or have taken too long to complete.

2160

Logging HttpUrlConnection requests

To log network request, use InstabugNetworkLog then use the following method at the HttpUrlConnection, Request body and response body

InstabugNetworkLog networkLog = new InstabugNetworkLog();
networkLog.Log(urlConnection, requestBody, responseBody);

For a more detailed example see the following network request

protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params){
  HttpURLConnection urlConnection = null;
  Java.IO.BufferedReader reader = null;
  String responseBody = null;
  try 
  {
    URL url = new URL("url");
    urlConnection = (HttpURLConnection)url.OpenConnection();
    urlConnection.RequestMethod="GET";
    urlConnection.UseCaches = false;
    urlConnection.ConnectTimeout=10000;
    urlConnection.ReadTimeout=10000;
    urlConnection.Connect();
    // Read the input stream into a String
    System.IO.Stream inputStream = urlConnection.InputStream;
    Java.Lang.StringBuffer buffer = new Java.Lang.StringBuffer();
    if (inputStream == null)
    {
      return null;
    }
    reader = new Java.IO.BufferedReader(new Java.IO.InputStreamReader(inputStream));
    String line;
    while ((line = reader.ReadLine()) != null)
    {
      buffer.Append(line + "\n");
    }
    if (buffer.Length() == 0)
    {
      return null;
    }
    responseBody = buffer.ToString();
    //logging network request to instabug
    InstabugNetworkLog networkLog = new InstabugNetworkLog();
    networkLog.Log(urlConnection, requestBody, responseBody);
    return jsonStr;
  }
  catch (IOException e)
  {
    Log.Error("LoginActivity","error: ",e);
    return null;
  }
  finally
  {
    if (urlConnection != null)
    {
      urlConnection.Disconnect();
    }
    if (reader != null)
    {
      try
      {
        reader.Close();
      }
      catch (IOException e) 
      {
        Log.Error("LoginActivity", "error: ", e);
      }
    }
  }
}

Instabug Logs

You can log messages throughout your application's lifecycle. Those logs are going to be sent with each report.

//iOS
IBGLog.LogInfo("info");
IBGLog.LogWarn("warning");
IBGLog.LogVerbose("verbose");
IBGLog.LogDebug("debug");
IBGLog.LogError("error");

//Android
InstabugLog.W("Warning message");
InstabugLog.E("Error message");
InstabugLog.I("Information message");
InstabugLog.V("Verbose message");
InstabugLog.D("Debug message");
InstabugLog.Wtf("Failure message");

Console Logs

Instabug automatically captures the console logs and display them on your dashboard with each report. We currently capture the console logs coming from the native code only.

If you don't want to send the console logs parallel with the report you can disable this feature as follows.

//Android
new Instabug.Builder(this, "ANDROID_APP_TOKEN")
            .SetInvocationEvent(InstabugInvocationEvent.Shake)
            .SetConsoleLogState(Feature.State.Disabled)
						.Build();

User Events

You can log custom user events throughout your application. Events are automatically going to be included with each report.

//iOS
Instabug.LogUserEventWithName("User Event");

//Android
//Not supported yet.

What’s Next

Logs go hand-in-hand with both bug reporting, so why not give that a look? The Session Profiler could also help give you more details alongside the logs.