Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #12706
| From | Lew <noone@lewscanon.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Quick Error Handling Question |
| Date | 2012-03-05 02:48 -0800 |
| Organization | albasani.net |
| Message-ID | <jj25mm$5ih$1@news.albasani.net> (permalink) |
| References | <XnsA00CCE30F52F5jpnasty@94.75.214.39> <4f541549$0$293$14726298@news.sunsite.dk> |
Arne Vajhøj wrote: > Novice wrote: >> I'm trying to learn more about Error Handling. I've read the Java Tutorial >> topic on it, as well as Bloch's Effective Java (2nd edition) tips on it. >> I've started on Robust Java by Stephen Stelting too. I know I'm going to >> have more questions later but one is bugging me right now and I'm not >> seeing it mentioned anywhere so let me ask now. >> >> Should I write stacktraces from my checked and unchecked exceptions to my >> log? Or just assume that all stacktraces will be written to the console and >> the console will always be accessible to everyone who needs it? > > In general I don't like multi line log messages, but stacktraces > are just too damn useful, so I would say log them anyway. This is where you use log levels. Log headlines at "error" level (SEVERE or ERROR depending on library). Think about what's appropriate for stack traces case by case. I usually log the trace at "debug" (FINE or DEBUG), but there isn't exactly a recipe. In case of trouble, the installation can play with log levels to open the information floodgates in relevant areas, then shut them off again after diagnostics. There is a principle, elucidated for you the other day. Logs are for troubleshooting. Make them useful for people when they're troubleshooting. Not for you just when you're developing, not for prettiness, not for confusion. Read your own log files and see what they tell you. Try them at different levels. Write unit tests that crash your code and see what's logged. Make them useful. Arne's suggestion is wise - when you need a stack trace and it isn't there, what now? Conversely, when you don't need it and it's there, what harm? (I say there is some - but how much?) If it's configurable in the field and you can get traces or not at will, how about that? -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Quick Error Handling Question Novice <novice@example..com> - 2012-03-05 01:10 +0000
Re: Quick Error Handling Question Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-03-04 17:20 -0800
Re: Quick Error Handling Question Arne Vajhøj <arne@vajhoej.dk> - 2012-03-04 20:29 -0500
Re: Quick Error Handling Question Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-03-04 17:35 -0800
Re: Quick Error Handling Question Arne Vajhøj <arne@vajhoej.dk> - 2012-03-04 20:58 -0500
Re: Quick Error Handling Question Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-03-04 18:11 -0800
Re: Quick Error Handling Question Arne Vajhøj <arne@vajhoej.dk> - 2012-03-04 21:42 -0500
Re: Quick Error Handling Question Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-03-04 19:26 -0800
Re: Quick Error Handling Question Arne Vajhøj <arne@vajhoej.dk> - 2012-03-04 22:44 -0500
Re: Quick Error Handling Question Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-03-04 21:20 -0800
Re: Quick Error Handling Question Arne Vajhøj <arne@vajhoej.dk> - 2012-03-09 21:26 -0500
Re: Quick Error Handling Question Arne Vajhøj <arne@vajhoej.dk> - 2012-03-04 20:22 -0500
Re: Quick Error Handling Question Lew <noone@lewscanon.com> - 2012-03-05 02:48 -0800
Re: Quick Error Handling Question Arne Vajhøj <arne@vajhoej.dk> - 2012-03-04 21:01 -0500
Re: Quick Error Handling Question Martin Gregorie <martin@address-in-sig.invalid> - 2012-03-05 22:59 +0000
Re: Quick Error Handling Question Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-03-05 19:55 -0400
Re: Quick Error Handling Question Martin Gregorie <martin@address-in-sig.invalid> - 2012-03-06 00:01 +0000
Re: Quick Error Handling Question markspace <-@.> - 2012-03-04 19:13 -0800
Re: Quick Error Handling Question Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2012-03-10 15:21 +0200
Re: Quick Error Handling Question Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-03-04 22:34 -0800
Re: Quick Error Handling Question Roedy Green <see_website@mindprod.com.invalid> - 2012-03-05 02:25 -0800
Re: Quick Error Handling Question Novice <novice@example..com> - 2012-03-05 13:51 +0000
csiph-web