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