Logging 如何使用企业库ExceptionManager添加有关异常的附加信息?
我有WCF服务,它有异常策略,比如Logging 如何使用企业库ExceptionManager添加有关异常的附加信息?,logging,enterprise-library,Logging,Enterprise Library,我有WCF服务,它有异常策略,比如 [ExceptionShielding("WCFErrorHandling")] public class Service : IService { public void Oepration1(long userId) { try { //Logic here } catch (BusinessException ex) {
[ExceptionShielding("WCFErrorHandling")]
public class Service : IService
{
public void Oepration1(long userId)
{
try
{
//Logic here
}
catch (BusinessException ex)
{
throw new FaultException<BusinessFault>(new BusinessFault() { Message = ex.Message });
}
}
}
所以,然后抛出businesexception
,一切正常,我可以在throw
时刻将userId放入businesexception
构造函数中,但当发生类型异常时:
System.Reflection.TargetInvocationException
无法添加用户ID字段,因为TargetInvocationException
是内置异常。我可以过度渲染,但我的项目有太多的例外。
所以,我需要知道,在每个例外情况下,用户ID,你会给我推荐什么
System.Reflection.TargetInvocationException