Monday, 21 March 2011

Android - How to capture application log

Here is some tutorials which shows the sample code to capture application log.

1. Android snippets:
http://www.androidsnippets.com/how-to-capture-application-log

2. The source code of aLogCat
http://code.google.com/p/alogcat/source/browse/
or you can get the read-only souce by using svn and then import it to eclipse:
svn checkout http://alogcat.googlecode.com/svn/trunk/ alogcat-read-only

Basically it calls Runtime.getRuntime().exec with a string which is the command to invoke the logcat, and then capture the output by a BufferedReader.

Note that the permission READ_LOGS should be requested in the manifest. (This line should be added in the Manifest file)
<uses-permission android:name="android.permission.READ_LOGS" />

For more information about Runtime:

No comments:

Post a Comment