Why doesn't Android print a stack trace?

Even by explicitly writing e.printStackTrace (), it does not print to the console, why?

+4
source share
4 answers

Place a Logcat order in the Logcat perspective, it should not be there on the Console tab.

Or use the ddms command tool to read the logarithm.

alt text

+7
source

printStackTrace() does not print to the console; it prints a standard error stream. If you want to print on the screen, set e.getMessage() or e.getStackTrace() for the displayed text. (Although I recommend learning to debug using logcat instead.)

+2
source

use Log.X (), where X is the type of error console you want (Log.e, Log.v, Log.d, etc.)

+1
source

You cannot print to the console on Android. You must use the Android Log class. When I have an exception and I want to print it, I use:

 for (StackTraceElement element : exception.getStackTrace()) Log.e("my_tag", element.toString()); 

or you can try

 String stackTrace = Log.getStackTraceString(throwable); 

And after that you can print it in Android Log.

+1
source

Source: https://habr.com/ru/post/1314876/


All Articles