Is it better to log exception
or exception.getMessage()
while logging an info log or an error log. I'm pretty sure that is related to the context but I'd like to know from a technical perspective on which would be better for any application or if its all the same.
newcoder310 0 Junior Poster in Training
Recommended Answers
Jump to Postthe error message itself is usually pointless. for all you know, some funny guy had code like this:
…try{ // code throwing whatever Exceptions } catch(AnyException aE){ throw new Exception("This message is pointless"); } catch(Exception e){ throw new Exception("Huh ... didn't see this one coming"); }
Jump to Postif you have so many exceptions that need logging that it affects performance there's more wrong with the system than just logging performance...
Exceptions should be rare, exceptions that need logging a stacktrace of because you don't know how to handle them should be even more rare.
All 8 Replies
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
stultuske 1,116 Posting Maven Featured Poster
newcoder310 0 Junior Poster in Training
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
jwenting 1,905 duckman Team Colleague
newcoder310 0 Junior Poster in Training
newcoder310 0 Junior Poster in Training
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.