0

I know there are several similar questions however, I couldn't figure out what is wrong with my code. I am trying to read the program logs and write them in an activity. I basically wanted to write only my tagged Debug and Error messages to show but it does still show logs I don't want. Here it is my code:

String[] command=new String[]{"logcat", "-d","-s","*:D"};
            Process process = Runtime.getRuntime().exec(command);
            BufferedReader bufferedReader = new BufferedReader(
                    new InputStreamReader(process.getInputStream()));

            StringBuilder log=new StringBuilder();
            String line;
            while ((line = bufferedReader.readLine()) != null) {

                log.append("\n"+line);
            }
            TextView txtLogs = (TextView)findViewById(R.id.txtLogs);
            txtLogs.setMovementMethod(new ScrollingMovementMethod());
            txtLogs.setText(log.toString());

and i have tags like ;

   Log.e(TAG, "Error onCreate() " + ex.getMessage());

and I am getting result like

D/ScanFragment(18675): message

Why do I get a log like 'message' ? thank you

codelife
  • 39
  • 2
  • u can filter logs. take a look at this.http://stackoverflow.com/questions/19931987/how-to-filter-logcat-in-android-studio – Kiran K May 20 '15 at 01:45
  • I actually did read this before but this is about using logcat on AndroidStudio however I ask programmatically how to do so. – codelife May 21 '15 at 01:30

0 Answers0