以下に示すように、c# のスタック トレースを txt ファイルに出力できるようにしたいと考えています。次の点に注意してください。
- Ex.Message がスタック トレースを取得しないことはわかっています。StackTrace メッセージをテキスト ファイルに書き込むためだけに FileHandler を使用したいと考えています。
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); }