开发者

WCF - Error Handling

开发者 https://www.devze.com 2022-12-15 16:39 出处:网络
I have my WCF Service hosted in Windows Service. The client application is a website project to which I added the Service reference.

I have my WCF Service hosted in Windows Service. The client application is a website project to which I added the Service reference.

I was not using any error logging/tr开发者_开发技巧acing... but now I feel I should implement as it will help me not to make void guesses.

Please guide me for the best practice so that I can quickly handle errors and pin point the exact issue.

Thank you!


If you just need to see the error message for troubleshooting purposes, you can set IncludeExceptionDetailInFaults attribute in your app.config. This will give you the full exception details, including a stack trace on your client. However, be aware that exception details may include sensitive information, so don't leave it on in a production system without understanding the risk.

If you want to take it a step further, you can implement the IErrorHandler interface. You can use this as a single point of logging exceptions or translating them into published Fault Contracts.


The first step to maintaining a more robust WCF Service is logging all operations made.

The Logging Application Block works for me. you might also want to check log4net.


If you're looking for general information on debugging WCF services, I recommend reading the following articles:

Debugging WCF Services

Configuring Message Logging

Configuring Tracing

Debugging WCF Services in Visual Studio 2008

0

精彩评论

暂无评论...
验证码 换一张
取 消