1

Can Anybody tell me how we can got the Logcat of particular application. I want to be create an application in which user choose the name of application e.g. radio, Facebook, Navigation etc. After choosing it user click on the button. After clicking on the button the log of the chosen application can be got in file or in any form...!!!

Thanx in Advance

Android Boy
  • 4,335
  • 6
  • 30
  • 58
  • 2
    logcat isn't individual to each application, there's just one logcat and every application uses it...at most you can grep through it, provided that application uses a keyword for each log entry (which is unlikely) – st0le Nov 18 '11 at 07:52
  • 1
    But when we want to get the log of radio then by the help of this command we can grep the log of radio... adb logcat -b radio – Android Boy Nov 18 '11 at 08:16
  • [See here](http://developer.android.com/guide/developing/tools/logcat.html) i don't think it does what you think it does. – st0le Nov 21 '11 at 05:14
  • I already see it, and by the help of it, I develop the application but there are some little mistake, I can't get actual solution...!!! – Android Boy Nov 21 '11 at 10:55

1 Answers1

3

Try this,

   String baseCommand = "logcat -v time";

        try {
              Process logReaderProcess = Runtime.getRuntime().exec(baseCommand);
              BufferedReader bufferedReader = new BufferedReader(
               new InputStreamReader(logReaderProcess.getInputStream()));

               while ((line =bufferedReader.readLine()) != null) {
                        log.append(line); // here readLine() returns null
                      }

        }
        catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
                }
user370305
  • 108,599
  • 23
  • 164
  • 151