Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Logcat window cuts off exception stack traces

My logcat window in Eclipse only displays the first few lines of the StackTrace for each exception. This means that I often can't see where an exception occured. Is there any way to change this setting?

like image 375
Casebash Avatar asked May 25 '10 03:05

Casebash


2 Answers

If you're referring to the "...12 more lines..." part, you only see that for exceptions that were the cause of another exception. If the top part of the stack trace is the same as the earlier trace, the full set of frames is only shown for the outermost exception, and the other traces get the "..." treatment.

Put another way, the chunk of a trace that isn't shown is a duplicate of a trace that appeared earlier in the exception cause chain. For example, suppose I have code where the method main() calls one(), which calls two(), and so on. four() throws an exception. two() catches it and re-throws it. The exception will look like this:

java.lang.RuntimeException: re-throw
    at Foo.two(Foo.java:14)
    at Foo.one(Foo.java:7)
    at Foo.main(Foo.java:3)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: first
    at Foo.four(Foo.java:23)
    at Foo.three(Foo.java:19)
    at Foo.two(Foo.java:12)
    ... 3 more

The "caused by" exception says "... 3 more" rather than explicitly listing one(), main(), and dalvik.system.NativeStart.main. So to get the full trace of the initial exception, you would start by reading its trace, then continue at the trace above.

Note there is no overlap -- two() appears in both, but in the "first" trace it's on the call to three(), and in the "re-throw" trace it's on the throw instruction.

like image 104
fadden Avatar answered Oct 17 '22 20:10

fadden


you can overload all the log methods (log.d, log.i, log.e, etc) with (String tag, String msg, Throwable tr) parameters, where the third parameter is the exception. This will give you the full stacktrace in logcat

http://developer.android.com/reference/android/util/Log.html

like image 36
aldo.roman.nurena Avatar answered Oct 17 '22 20:10

aldo.roman.nurena