Android打印堆栈跟踪
我如何获得与Android中的printStackTrace等效的结果?我知道我可以通过将标记名称和字符串传递给日志记录方法来记录错误,但这只是给了我一个nullpointerexception.如果我调用e.printStackTrace(),此数据将打印到哪里?
How can I get the equivalent of a printStackTrace in android? I know I can log an error, by passing in a tag name and a String to the logging method, but that just gives me a nullpointerexception. If I call e.printStackTrace(), where is this data printed to?
如果您使用的是eclipse,请确保已打开 LogCat
窗口.您可以在
If you are using eclipse make sure you have LogCat
window opended. You can find it under
窗口->显示视图->其他->在Android下-> LogCat
更新:2014年7月
或者,如果您使用的是Android Studio,则可以在
OR if you are using Android Studio you can find it under
窗口菜单->显示视图-> Logcat
LogCat
就像普通JAVA中的控制台一样.您的 e.printstacktrace()
也将出现在LogCat中.
LogCat
is like a console in normal JAVA. Your e.printstacktrace()
would appear in LogCat as well.