2017-08-21 96 views
0

在下面的代码中,args.Exception.ToString()(或args.Exception.StackTrace)仅返回引发异常的方法名称和行,但不返回完整的调用堆栈。PostSharp异常堆栈跟踪未完成

public override void OnException(MethodExecutionArgs args) 
    { 
     Logger.GetLogger().Write(LogLevel.Error, args.Exception.ToString());    
    } 

但下面的代码给出了完整的调用堆栈

catch (Exception ex) 
{ 
    Console.WriteLine(ex); 
} 

我怎样才能得到充分调用堆栈中PostSharp与MethodExecutionArgs?

+0

你使用什么版本的PostSharp?它在5.0.32中运行良好。你有没有尝试'Console.WriteLine(args.Exception.ToString());'在'OnException'中?也许问题是记录器相关的(堆栈跟踪是多行)。 –

回答

0

问题不在于PostSharp,而在于我的代码。我在整个程序集而不是调用者处应用了[SwallowException]。 另外,Logger.GetLogger()。Write()支持多行。 谢谢Jakub。