1, Using ADB Tools:
Simply, run this command on a adb shell
<span style="font-size:14px;">logcat [-d | -e | ...]</span>
For more details, see:
http://developer.android.com/tools/help/adb.html#logcat
2, Android Apps:
Required permissions in AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_LOGS" />
Process process = Runtime.getRuntime().exec("logcat -d");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
So the output of command "logcat -d" is encapsulated into a BufferedReader, with which we can read the logcat content:
StringBuilder log=new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
log.append(line);
}