How to get the Stack trace when logging exceptions with NLog?

后端 未结 4 686
甜味超标
甜味超标 2020-12-23 15:57

When I use the default layout with NLog it only prints the name of the exception. I\'ve been told that the log4jxmlevent layout doesn\'t prints nothing about the exception.

4条回答
  •  时光说笑
    2020-12-23 16:51

    I had to use the one of the Logger. + Level + Exception methods:

    logger.ErrorException("ex", ex);
    

    and a custom layout

    layout="${exception:format=ToString,StackTrace}${newline}"
    

提交回复
热议问题