Reputation: 16844
I have a C# WCF application running on IIS 7.5.
If an exception is thrown I get the generic request failed page. In order to find the guilty code, I'd like to get a full stack trace including line numbers and file names. How can I do that?
Whether the stack is returned directly or logged internaly on the server doesn't matter, as long I can see what is causing the error.
Update: Thanks for the answers so far. Unfortunately I'm a IIS/c# newbee. Are there any tutorials or step by step instructions? I've just no clue what to do with the answers so far.
Upvotes: 1
Views: 2431
Reputation: 1
I added a program I called ExceptionTrace to the http://stackdump.codeplex.com/ project in version 4. 1 Beta that will trace all generated exceptions without any changes in the code. It only attach itself as a debugger and listen to all generated exceptions.
Upvotes: 0
Reputation: 65564
Put calls in Try-Catch statements to log the error. The ASP.Net Tracing function is perfect for this task.
Or bubble up the exception to a logging function passing in and logging the Exception.StackTrace
.
Do it in one foul swoop using the AppDomain.CurrentDomain.UnhandledException
@paul mentions.
Upvotes: 0
Reputation: 26737
you can provide more information With FaultExceptions
http://msdn.microsoft.com/en-us/library/ms576199.aspx
some examples:
http://www.c-sharpcorner.com/uploadfile/afenster/wcf-error-handling-and-faultexceptions/
Upvotes: 1
Reputation: 22001
you could use a couple of event handlers in your code to call some logging function
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
and
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
also, you should set includeExceptionDetailInFaults=true
in your service behaviour configuration
Upvotes: 1