Des*_*ith -2 c# stack-trace file-handling
我希望能够将c#中的堆栈跟踪打印到txt文件中,如下所述.请注意以下内容:
FileHandler类内部代码并不重要.我想知道如何获取此处捕获的异常的堆栈跟踪.
try
{
//some code
}
// I just inherit from exception class (the message member, nothing big here)
catch (CustomException ex)
{
//I want to write the stacktrace here instead of the ex.Message
FileHandler.Write("DeveloperErrors.txt", "Stack Trace" + ex.Message, System.IO.FileMode.Append);
}
Run Code Online (Sandbox Code Playgroud)