Splunk MINT SDK for Android

Splunk MINT SDK for Android Developer Guide

Download manual as PDF

Download topic as PDF

Report LogCat output

LogCat is the Android logging system that lets you collect and view system debug output. To investigate how your app and user devices affect each other, you can instruct your app to send LogCat output with a crash report.

Note If you enable LogCat logging, only unhandled exceptions will contain the LogCat output.
  1. To send LogCat output with your exceptions, add the following line to your app's AndroidManifest.xml file:
  2. <uses-permission android:name="android.permission.READ_LOGS" />
    

    Splunk MINT uses this permission to read the LogCat output.

    Note The READ_LOGS permission instructs the app to report the entire LogCat output, including passwords and other sensitive data that your app collects. Take care when storing and sharing this data.

  3. To enable LogCat logging, use the enableLogging method as follows:
  4. Mint.enableLogging(true);
    
  5. Optionally, to restrict the number of lines or to set a filter string for log output, use the setLogging method with additional parameters:
    • setLogging(lines)
    • setLogging(filter)
    • setLogging(lines, filter)

    The following code shows examples of using the setLogging method with different filter expressions:

    // Log the last 100 messages
    Mint.setLogging(100);
    
    // Log all messages with priority level "warning" and higher, on all tags
    Mint.setLogging("*:W");
    
    // Log the latest 100 messages with priority level "warning" and higher,
    // on all tags
    Mint.setLogging(100, "*:W");
    
    // Log all messages from the ActivityManager at priority "Info" or above,
    // all log messages with tag "MyApp", with priority "Debug" or above:
    Mint.setLogging(400, "ActivityManager:I MyApp:D *:S");
    

    By default, Splunk MINT sends the last 500 lines with no filter. Splunk MINT filtering uses the same filtering mechanism as LogCat. For more information about filter expressions, see Filtering Log Output on the Android Developers website.

To examine the LogCat output:

  1. Go to the Errors dashboard in Splunk MINT Management Console and click an error.
  2. On the error details page, click Error Instances above the table.
  3. In the View Logs column, click the icon to view a log file for a particular error instance.


Example AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.splunk.mint.example"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_LOGS"
/>
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <application
        ...
    </application>
</manifest>


Example code

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // TODO: Update with your API key
    Mint.initAndStartSession(this.getApplication(), "YOUR_API_KEY");

    // Enable logging
    Mint.enableLogging(true);

    // Log last 100 messages
    Mint.setLogging(100);

    setContentView(R.layout.main);

    // Continue with your code
}
PREVIOUS
Report network calls manually
  NEXT
Report debugging messages

This documentation applies to the following versions of Splunk MINT SDK for Android: 5.2.x


Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters