root.debug("%throwable{100}, with exception", ex);
//
// manufacture a pattern to get just the first two lines
//
String[] trace = new ThrowableInformation(ex).getThrowableStrRep();
layout.setConversionPattern("%m%n%throwable{" + (2 - trace.length) + "}");
layout.activateOptions();
root.debug("%throwable{-n}, no exception");
root.debug("%throwable{-n}, with exception", ex);