I have code that looks like the following, which works fine for displaying the message, but can't figure out any way to get a hold of the stack trace.
我有类似下面的代码,它可以很好地显示消息,但无法找出任何方法来获取堆栈跟踪。
try {
throw new RuntimeException("This is bad stuff!");
} catch (Exception e ) {
mainForm.append("Exception: " + e.getMessage());
}
Calling e.printStackTrace() sends it somewhere that I can't find.
调用e.printStackTrace()将它发送到我找不到的地方。
4 个解决方案
#1
4
see this article: http://lwuit.blogspot.com/2008/12/redirecting-output-on-s60-devices.html
看到这篇文章:http://lwuit.blogspot.com/2008/12/redirecting-output-on-s60-devices.html
too bad there is no System.setErr(PrintWriter) or Thread.getStackTrace()
太糟糕了没有System.setErr(PrintWriter)或Thread.getStackTrace()
I don't think there is a (generic) solution for this problem
我不认为这个问题有(通用)解决方案
#2
1
No, you can't. Stack trace is always printed to System.err and there is no way in CLDC to redirect System.err to somewhere else.
不,你不能。堆栈跟踪始终打印到System.err,并且CLDC无法将System.err重定向到其他位置。
#3
1
Even in CLDC 1.1 this does not exist.. hope Sun includes redirection of error and out stream in future versions. It is very essential of logging/debugging.
即使在CLDC 1.1中,这也不存在。希望Sun在未来版本中包含错误重定向和流出。记录/调试非常重要。
#4
0
I've created a tool that can be used to log proper stack traces also in CLDC. Check it out at http://jarrut.sourceforge.net. It's still very new and it might have some rough edges, but it works for me and I couldn't imagine developing MIDlets without it anymore. Best way to use it is to combine it with microlog.
我已经创建了一个工具,可用于在CLDC中记录正确的堆栈跟踪。请访问http://jarrut.sourceforge.net查看。它仍然是非常新的,它可能有一些粗糙的边缘,但它适用于我,我无法想象没有它开发MIDlet。最好的方法是将它与microlog结合使用。
#1
4
see this article: http://lwuit.blogspot.com/2008/12/redirecting-output-on-s60-devices.html
看到这篇文章:http://lwuit.blogspot.com/2008/12/redirecting-output-on-s60-devices.html
too bad there is no System.setErr(PrintWriter) or Thread.getStackTrace()
太糟糕了没有System.setErr(PrintWriter)或Thread.getStackTrace()
I don't think there is a (generic) solution for this problem
我不认为这个问题有(通用)解决方案
#2
1
No, you can't. Stack trace is always printed to System.err and there is no way in CLDC to redirect System.err to somewhere else.
不,你不能。堆栈跟踪始终打印到System.err,并且CLDC无法将System.err重定向到其他位置。
#3
1
Even in CLDC 1.1 this does not exist.. hope Sun includes redirection of error and out stream in future versions. It is very essential of logging/debugging.
即使在CLDC 1.1中,这也不存在。希望Sun在未来版本中包含错误重定向和流出。记录/调试非常重要。
#4
0
I've created a tool that can be used to log proper stack traces also in CLDC. Check it out at http://jarrut.sourceforge.net. It's still very new and it might have some rough edges, but it works for me and I couldn't imagine developing MIDlets without it anymore. Best way to use it is to combine it with microlog.
我已经创建了一个工具,可用于在CLDC中记录正确的堆栈跟踪。请访问http://jarrut.sourceforge.net查看。它仍然是非常新的,它可能有一些粗糙的边缘,但它适用于我,我无法想象没有它开发MIDlet。最好的方法是将它与microlog结合使用。