How can I convert a stack trace to a string?

前端 未结 30 1491
再見小時候
再見小時候 2020-11-22 14:51

What is the easiest way to convert the result of Throwable.getStackTrace() to a string that depicts the stacktrace?

30条回答
  •  旧巷少年郎
    2020-11-22 15:02

    Arrays.toString(thrown.getStackTrace())
    

    Is the easiest way to convert the result into String I am using this in my program to print the stack trace

    LOGGER.log(Level.SEVERE, "Query Builder Issue Stack Trace : {0} ,Message : {1} objid {2}", new Object[]{Arrays.toString(e.getStackTrace()), e.getMessage(),objId});
    

提交回复
热议问题