Read Logs programmatically in Android

In this blog you will learn how to read logs programmatically in Android and used for bug report purposes.

Its easy to read logs from Logcat and debug the application. But what if you have requirement of collecting that logs and send it as report to server?

Now what to do? Don’t worry. Android allow user to access logs in their application. How? Just go through following steps.

Step 1

Write following line in your AndroidManifest.xml (Read more about what is AndroidManifest.xml) file to give permission to read logs.

Step 2

Copy paste following code snippet in your application. This class has readLog() method which return you logs read by that method.

Now everything is done. If you want to read logs in application, just use

LogsUtil.readLogs();

You can also use more options and filters while reading logs. Please read Reading and Writing Logs.

Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Pin on Pinterest0Share on Tumblr0Email this to someone