0

I have gone through many tutorials, but I haven't found how to get the error logs.

I found one link: http://www.helloandroid.com/tutorials/reading-logs-programatically

and gone through it. I want only error logs, I don't know which command must write to show error logs. My requirement is to send the logs through email, I don't want any adb command. I want the command to write in java to read the logs of error/debug/info.

Example: to dump a file, they have written code like

Process process = Runtime.getRuntime().exec("logcat -d"); 

To print only error logs, what command should I write?

Gone through Andorid Developers Blog: http://developer.android.com/tools/debugging/debugging-log.html

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • possible duplicate of [Write android logcat data to a file](http://stackoverflow.com/questions/6175002/write-android-logcat-data-to-a-file) – karan Aug 31 '15 at 05:54

2 Answers2

1
Process process = Runtime.getRuntime().exec("logcat -d *:E");
Adriaan
  • 17,741
  • 7
  • 42
  • 75
Lessi
  • 11
  • 1
  • 5
    Welcome to Stack Overflow! Please read [answer] and [edit] your answer to include an explanation as to **why** this code would solve the problem at hand. Always remember you're not only answering the question, but also have to make it understandable for any future readers of this post (especially when answering 5 year old questions) – Adriaan Jun 09 '20 at 11:35
0

If you want an error log, just write: Log.e("MyClass", "This is an error");

And if you want to display errors only, just change the log level in Android Studio like this: Logcat log level

jfmg
  • 2,626
  • 1
  • 24
  • 32