How to get and log the Exception Stack

  • Thread starter Thread starter Mullin Yu
  • Start date Start date
M

Mullin Yu

I have some c# web services and c# application. I want to get and log the
Exception Stack beside the exception message got from catch(Exception ex).

Which class and method can do what I want? If possible, I want to log them
into event viewer.

Thanks!
 
Hi,

The ToString() method of the Exception object gives a description of the
exception including the complete stack trace, if all you want is the stack
trach there is also the StackTrace method that returns a string
representation of the stack trace.

To use the event log, you can look at the EventLog class.

Hope this helps
 
Back
Top