Scala: print a stack trace in my Scalatra app

后端 未结 4 1391
萌比男神i
萌比男神i 2021-02-13 18:02

Seems like a fairly straight forward problem, but I\'d like to log a stack trace when my top level error handler in Scalatra is triggered. I\'m intentionally throwing an excepti

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-13 18:52

    Use ExceptionUtils from Apache Commons Lang:

    import org.apache.commons.lang3.exception.ExceptionUtils
    (...)
    logger.info("an exception occurred: " + ExceptionUtils.getStackTrace(e))
    

提交回复
热议问题