Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Globally Log Catch Exception e

Suppose that I have a legacy java application with thousands of lines of code which do:

try {
   // stuff 
} catch (Exception e) {
   // eat the exception
}

Is there any global option that I could flip or 3rd party JAR which would log all "eaten" exceptions? I know that I could do a massive find replace (search for catch (Exception e) { and replace it with catch(Exception e) { logException(e);) but I was wondering if there was a better solution. Thanks!

like image 341
sqlBugs Avatar asked May 12 '10 15:05

sqlBugs


1 Answers

You could perhaps provide your own implementation of Exception which logs the stack-trace in the constructor. From the man page of java:

-Xbootclasspath:bootclasspath
Specify a colon-separated list of directories, JAR archives, and ZIP archives to search for boot class files. These are used in place of the boot class files included in the Java 2 SDK.

like image 108
aioobe Avatar answered Sep 19 '22 09:09

aioobe