Probably a newbie question, but everyone seems to use e.printStackTrace()
, but I have always used System.out.println(e)
when exception handling. What i
Since the output of e.printStackTrace();
is System.err
and usually I output my app log to a file, I recommend you to use both System.err
and System.out
to output errors.
public static void log(Exception e) {
e.printStackTrace(); // This goes to System.err
e.printStackTrace(System.out);
}
This way you can see the errors in the log file (in case you have one) and in the console.