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.
- To send LogCat output with your exceptions, add the following line to your app's AndroidManifest.xml file:
- To enable LogCat logging, use the enableLogging method as follows:
- 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)
<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.
Mint.enableLogging(true);
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:
- Go to the Errors dashboard in Splunk MINT Management Console and click an error.
- On the error details page, click Error Instances above the table.
- 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 }
Report network calls manually | Report debugging messages |
This documentation applies to the following versions of Splunk MINT™ SDK for Android (Legacy): 5.2.x
Feedback submitted, thanks!