Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 229
Registered: ‎11-21-2009
My Device: Not Specified

Stack Trace Capture (sorely needed)

 

Is there a way to capture the stack trace or even capture stdout on the device?

 

If not, surely this is important enough for app diagnostics that it could be easily added...

 

If so, could someone point me in the right direction....

 

 

  Thanks in advance....

 

 

  Ted

Developer
Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Re: Stack Trace Capture (sorely needed)

Try using the EventLog. You can write to the EventLog then to view it you can press alt-lglg on your device. You can also set the level of logging like Warning, Debug and Error. In the EventLog viewer you can also filter it so that only the logs generated by you application will appear on the screen. :smileyhappy:

 

Example :

EventLogger.logEvent(guid, "logging example", EventLogger.DEBUG_INFO);

--------------------------------------------------
problemSolved() ? kudosPlease():kudosPlease();
Developer
Posts: 229
Registered: ‎11-21-2009
My Device: Not Specified

Re: Stack Trace Capture (sorely needed)

Ok...

 

So how can I write it to the event log?  I don't see a way to write the Stack Frames...e.printStackTrace() only writes to stdout?

 

And the Alt-lglg - do you mean literally press the Alt key and then the "l" key, then the "g" key, etc..etc...

 

And last does this work on the physical device?

Developer
Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Re: Stack Trace Capture (sorely needed)

To completey understand what EventLog is and how you can write events to it, please take a look at thsi video tutorial:

 

http://www.blackberry.com/DevMediaLibrary/view.do?name=eventlog

 

Yes, it works both on physcial device and simulator.  I meant hold the Alt key and press "l" key, then the "g" key, etc..etc...

--------------------------------------------------
problemSolved() ? kudosPlease():kudosPlease();
Developer
Posts: 229
Registered: ‎11-21-2009
My Device: Not Specified

Re: Stack Trace Capture (sorely needed)

I already write to the EventLog and I use the EventLogger.startEventLogViewer(); call as a Menu pick when my app is in Debug mode...

But all it does is log the exception message - I read somewhere where the ONLY way it writes to the event log by default (an exception) is if it is uncaught...which is strange...

I want to catch the event and then write the trace to a popup or eventlog or anywhere...near as I can see, there is no way to write an exception stack frame after catching it...on my other java implementations, I use e.printStackTrace(OutputStream out) and just set out to stdout...

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Stack Trace Capture (sorely needed)

But your code doesn't crash does it!  :smileyhappy:

 

The ability to capture this information in an application was one of the top requests at DevCon, at least in the 'round tbale' sessin I went to.  So fingers crossed it will come soon.

 

I imagine there are some security issues with providing it.

Developer
Posts: 229
Registered: ‎11-21-2009
My Device: Not Specified

Re: Stack Trace Capture (sorely needed)

But I am correct in that the only way a trace gets written to EventLog is IF nothing catches it?

 

That is what I am seeing...

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Stack Trace Capture (sorely needed)

If you catch Throwable, then you can create a stack trace.  There is a KB article about it I think, or search the forum.

Developer
Posts: 229
Registered: ‎11-21-2009
My Device: Not Specified

Re: Stack Trace Capture (sorely needed)

I see no way to capture the stack frames...no calls on throwable...it's not in the .toString() of throwable...there's no redirect on stdout...etc...

 

I don't see where they left an option to do this?

Developer
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: Stack Trace Capture (sorely needed)

I think the case is, as mentioned elsewhere, if you catch an exception, then you do not get a stack trace: if you do not catch it, then you get one.