This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Logging stack trace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Logging stack trace" Watch "Logging stack trace" New topic
Author

Logging stack trace

Mikael Månsson
Greenhorn

Joined: Sep 20, 2009
Posts: 17
Hi

I am using the standard java logger, and i'm wondering about stack traces.

Normally, not using a logger, i would propagate all lower level exceptions as higher level exceptions up to the last place, the gui, and there I would present the user with an understandable error message. At the same time, for debugging, i would want to call the printstacktrace method on the exception so that I can see in what file and what line the exception occured.

Now, when I am using the logger, I would want to log both the message from the error and the stack trace for the same kind of tracability, but i don't find any simple way of doing this, is this not a common thing to do?

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5139
    
  12

Hi Mikael,

Logging is not a requirement, so I didn't logged any error. The only logging is used was some helpful debug information (parameters and return value of each method from the Data class and my business service).

To show the user a message I used this code:
And maybe this link can help you to log an exception using JUL.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logging stack trace
 
Similar Threads
Exception stack trace in logger
exception stack trace not going to log file
NX: Logging using FileHandler
Exception propagation in layered applications
"Double" and "double" - what's the difference?