News for hackers. Stuff that matters.
Re:Great Programmers Write Debuggable Code by xaphod on Monday May 06, 2013 @07:16AM (#5661782)
One important aspect of logging is to include enough information when something fails. This sounds like it should be common sense, but I have seen this too many times:

java.net.ConnectionException: Connection refused ...

Why not include at least the hostname and port? And what connection is this exactly that failed? You might be able to find out what it was trying to connect to based on the stack trace, but that requires knowledge of the internal structure of the software.

This seems to be a common problem in software written in Java, I don't know why exactly. Maybe something to do with the way exceptions are handled, so that the relevant information is not available when printing the error?

Re:Great Programmers Write Debuggable Code by henrik_w on Monday May 06, 2013 @07:21AM (#5661794)
So true! One of my pet peeves! Truly pathetic to not include dynamic info like hostname, port and reason.

Who are these people writing code like that - they never had to debug a problem before? Include as much as you can! A stack trace is only part of the story.

Re:Great Programmers Write Debuggable Code by noss on Monday May 06, 2013 @10:56AM (#5662722)
Definitely, I often catch exceptions and wrap them just to add more information from the try-finally scope. It is so frequently useful to get a full story of what the app was attempting to do.