Programmatically get log cat data
Asked Answered
M

1

2

i want to get logcat data programmatically i used the below code

 StringBuilder debuglog=new StringBuilder();
        try {
            Process process = Runtime.getRuntime().exec("logcat -d");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line;

            while ((line = bufferedReader.readLine()) != null) {

                debuglog.append(line);
                debuglog.append("\r\n");
            }
            } catch (IOException e) {
                e.printStackTrace();
            }

Above code is working fine

This line "logcat -d" shows -d,-w,-i messages

But,my problem is i want to show -e messages

Mosul answered 11/2, 2013 at 10:0 Comment(1)
Does not work anymore with Android 4.1 :-(Detour
H
4

To get only ERROR use this:

Process process = Runtime.getRuntime().exec("logcat -d *:E");
Holt answered 11/2, 2013 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.