You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by Mario Cormier <mc...@miranda.com> on 2003/08/11 17:27:30 UTC
Logging exceptions without a message
Working with Xindice, I sometimes get a bunch of lines in my log that
look like:
15827 [Thread-32] WARN indexer.ValueIndexer -
java.lang.NullPointerException
without any stack trace available. Now this isn't very useful when
trying to figure out what went wrong and where. The problem stems (I
assume) from a small misunderstanding regarding the logging API. You
*can* pass an Exception as the only parameter to methods like
Log.warn(), but they won't be interpreted as Exceptions: they'll be
treated just like any other Object, and the logging system will simply
call .toString() on them and log the result and nothing more.
So it turns out that changing:
try {
// ...
} catch (Exception e) {
log.warn(e);
}
to:
try {
// ...
} catch (Exception e) {
log.warn("", e);
}
would already be a big improvement, and of course having a meaningful
description instead of "" would be even better. :) I could roll up my
sleeves and submit a patch later on if you guys are interested, but
unfortunately I can't get on it right away. This thing called "work"
getting in the way. :)
Keep up the great work!
Mario
_________________________
Mario Cormier
Miranda Technologies Inc.
http://www.miranda.com/