Capture Complete LOGS on Android

I was wondering how I am fetching full logs from an Android device (from the moment my application initializes to any crash or until my application closes).

The reason I am posting is my application crashed at some point, but when I fetch the logs using DDMS / Logcat my crash data is overwritten with new logs.

How can I get crashed cause logs ...

A special look at capturing Native Code Crash.

ie I/DEBUG (21835): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000004...

Will this adb logcat> crash.txt guarantee that the file will be written to forever?


source to share

6 answers

I tried it It really works Well, not sure how much battery it will consume. If your application is under testing, you can use this. Before release, you need to remove this code and publish ..

private void writeADBLogs(){
     BufferedWriter bufferedWriter = null;

      try {
         final File file = new File(sdcardPath);
        bufferedWriter = new BufferedWriter(new FileWriter(file,true));
        Process process = Runtime.getRuntime().exec("logcat -d");
        BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(process.getInputStream()));

        String oneLine;
          while ((oneLine= bufferedReader.readLine()) != null) {
    } catch (IOException e) {




Android log will only be saved when your application has Debugging = true in the manifest (for example, when you are in debug mode).

See the documentation on Disable Logging and Debugging

So if you want a log, you can implement Thread.setDefaultUncaughtExceptionHandler (Thread.UncaughtExceptionHandler)

This will be called whenever your application is forced to close due to an exception.

What you do is save the StackTrace to a file in append mode.

You can also use this in debug mode.

LogCat is a queue, so there are changes you miss in your log (the old log will be automatically discarded).

I suggest you implement setDefaultUncaughtExceptionHandler so that you never miss any exception log. Also take care to delete the file after use, otherwise your file will become very large in size.



install aLogCat , then if your app crashes, run it. Use a filter (from the menu) to narrow the data down to your app and eventually save it or mail it from your device. But that won't do much magic - if the logs phishically disappear from the device, it won't send you more than you can have with DDMS. However, this is very useful if your users are reporting crashes.



Assuming you have access to the device:

  • Connect your device to your computer.
  • Launch DDMS, select the device and go to the file explorer tab.
  • Find the file listed in LogCat and click the Pull From Device button at the top.


Logtags , cat . . getPackageName() - , .

Eclipse +, LogCats. " ".

" ", Eclipse, , , .

Android Developer Bridge. adb logcat

- , , , , . :)


You can use acra with your application. This will help you get crash reports on your gdoc account, you can also configure it to get an email to report crashes. When your app goes live, it will also help you get a crash report.



All Articles