log4j print stacktrace code example Example: log4j print stacktrace try { ... } catch (Exception e) { log.error( "failed!", e ); }