0

I'm using java.util.logging.Logger to log caught exceptions.

Here's the code snippet:

for ( int x = 0; x < 25; x++ ) {

    try {

         throw new Exception("hi mom!");

    } catch (final Exception e) {

        LOGGER.log(Level.SEVERE, ": RUNTIME EXCEPTION raised.", e);

    }
}

I've observed that sometimes, when the exception is raised like 7 or more time, only the initial few will display the Stacktrace.

i.e:

java.lang.ArrayIndexOutOfBoundsException

instead of

java.lang.ArrayIndexOutOfBoundsException: -2
at java.util.ArrayList.get(ArrayList.java:324)
at .........

Furthermore, I'm now able to constantly reproduce it such that I never get the stack trace on my deployed system, but when I attach a debugger the system, the log always spits out the stack (even with no breakpoints).

I would've thought that it's some config issue where if in debug mode, then print the stack trace, otherwise don't. But as above, there are cases in operation where the stack trace is printed sometimes but not others, all off the same build.

Is there any java logging configs which I could take a look at? Any other ideas?

Matt Clark
  • 27,671
  • 19
  • 68
  • 123
Jimmy T
  • 447
  • 6
  • 14

0 Answers0