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

后端 未结 4 706
甜味超标
甜味超标 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:48

    As of NLog 4.5 you can now use:

    logger.Error(exception, message);

    and layout as follows:

    "${longdate} ${level} ${message} ${exception:format=@}"

    The @ means serialize all Exception-properties into Json-format

提交回复
热议问题