Java Reference
In-Depth Information
Figure 5-2. Extremely simplistic logging
However, this does not tell us much about what has happened but only that we have
decided to ignore the exception. In this particular case, it is fairly easy to see which line caught
that particular exception, and what it did with it. But what if we were running on a server, and
the getLock method could have been called from any one of a number of different methods?
In such a case, a stack trace might be useful to see why our getLock method was called. So we
could use more sophisticated logging, as shown in the following code and in Figure 5-3:
38 } catch (InterruptedException ie) {
39a log.log(Level.WARNING,
39b "Ignoring InterruptedException in transaction",
39c ie);
40 }
Figure 5-3. More detailed logging
Search WWH ::




Custom Search