如何使用Log4Net.ErrorFormat记录堆栈跟踪? [英] Using Log4Net.ErrorFormat how can I log the stacktrace?

查看:162
本文介绍了如何使用Log4Net.ErrorFormat记录堆栈跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用ErrorFormat方法,因为它更易于阅读,更安全,更快捷. 但我也想记录异常stacktrace.

I would like to use ErrorFormat method because it is easer to read, safer and faster. But I also want to log the exception stacktrace.

我尝试了log.ErrorFormat("My {0} message", "pretty", exception);

但是它仅记录我的漂亮消息" 是否可以通过这种方式使用错误/调试/信息格式?

But it only logs "My pretty message" Is it possible to use Error/Debug/Info Format in such way?

谢谢.

推荐答案

怎么样:

log.ErrorFormat("My {0} message: {1}", "pretty", exception);

这篇关于如何使用Log4Net.ErrorFormat记录堆栈跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆