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.

You may also like to read

APK Analysis : Spotlight on WhatsApp | How to use ... Android Studio includes an APK Analyzer that provides immediate insight into the composition of your APK after the build process is complete. In th...
Resizable Rectangle Overlay on Touch in Android When I read this question http://stackoverflow.com/questions/8974088/how-to-create-a-resizable-rectangle-with-user-touch-events-on-android on StackOve...
Exit from Activity with twice “Back” b... When we are doing some important operation or work on activity and it may possible that by mistake we pressed "back" button. Then what?? This will sim...
Android Unique Identification Number Some times, when we are integrate our android application with server, its requirement of server that it can identify every android device uniquely. S...
Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Pin on Pinterest0Share on Tumblr0Email this to someone