Java console output in 2.5

In the Mendix 2.5 application the console no longer shows the Java console output (e.g. anything printed to System.out) by default. I know I can see logging messages by using Core.getLogger(...), and that if it stops with an exception it'll show me the stack trace in a dialog. But in a couple of cases I do need System.out, e.g. if I want to see the stack trace of an exception I've caught without throwing it again. Where does System.out now go?
2 answers

The recommended option for showing log info (such as stacktraces) is to create your own logger.

Simply call

Core.getLogger("MartinsStacktraceLogger").info("my error message")

and it'll show up in your logs. Optionally, you can add an extra parameter of type Exception:

catch (Exception e) {
  Core.getLogger("MartinsStacktraceLogger").info("my error message", e);

which will then also include the entire stacktrace in the log message.

To answer your original question (where does the console output go), it depends on where you're running the runtime from. If you run it in eclipse, it'll show up in the eclipse console output. The modeler simply doesn't show the console output.


You can easily obtain the stacktrace of an exception using the following java code:

String stack = "";
if (e != null)
  stack = org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e);