的System.Exception是否有一个内置的抛出戳? [英] Does System.Exception have a built-in thrown timestamp?
本文介绍了的System.Exception是否有一个内置的抛出戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法来提取,当异常是从异常本身抛出,否则我将需要手动添加这些信息到异常?
Is there a way to extract when an exception was thrown from the exception itself, or will I need to manually add this information to the exception?
推荐答案
有没有内置的时间戳
属性对于异常
对象。您可以创建一个新的类继承自异常
并添加自己的属性。
There is no built-in Timestamp
property for the Exception
object. You can create a new class that inherits from Exception
and add your own property.
如果您使用的是作为例外的日志框架的参数,你可能想直接处理时间戳在日志框架(最有可能使用 DateTime.Now
/ UtcNow
)。
If you're using your exception as a parameter of a log framework, you might want to handle the timestamp directly in the log framework (most probably using DateTime.Now
/ UtcNow
).
这篇关于的System.Exception是否有一个内置的抛出戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文