WSSF (WCF) and Enterprise Library 3.1

Topics: General Discussion Forum, July and December Releases Forum
Jan 25, 2008 at 3:00 PM
This is not a post about health monitoring but my goal is to be able to monitor my WCF-service when put in production. What is best practice when it comes to Exception Handling and Logging when using WSSF with WCF?

I know this is a very general question that depends on many things and includes many things, but I also want a relative general answer. Can anybody come with some hints and guidelines on how YOU have set up your exception handling and logging so that others can get a kick-start on their way to make their system easy to monitor, track problems etc.

I would like many different approaches as possible here, so come on...!!!

Jan 29, 2008 at 10:50 PM
As a head start, you have "Exception Shielding" in EntLib that may give you a good guide on how to handle exceptions with logging capabilities in a secure way (that's why the shielding area) and then you also have the tracing features of WCF as well (quite documented in WCF docs et al.).
You can also find quickstars and examples of exception handling and logging in WSSFv2.
Jan 30, 2008 at 11:10 AM
Edited Jan 30, 2008 at 12:07 PM
Thanks Charly,
I thing I've got the overview of the EntLib, I know about the Exception Shielding and why you should use it. But I wonder what is done in practice by you pro's out there. Is it common practice to have a try-catch in every method of the service implementation so that every unhandled exception is catched and handeld by the Exception Shielding? Like this:

EntLibDemoEngine engine = new EntLibDemoEngine();

public string GetHelloWorldMessage()
return engine.HelloWorld();
catch(Exception ex)
if (ExceptionPolicy.HandleException(ex, "WCF Exception Shielding")) throw;
return null;

You have places in your code where you know an exception may occur, these places you put an try-catch and log with the LAB, but how do you handle all those other that you dont know about yet? Does anyone have some good experience here?

I may ask a bit detailed here but I think its a good discussion.... which more people would like to read and learn.
Jan 30, 2008 at 5:06 PM
As I mentioned on my first post in this thread, you can find some examples in the form of a Reference Implementation (WCF and ASMX) in the previous version of WSSF (v2).
There you will handle exceptions and logging in a completly cross-cutting or orthogonal way so you don't need to touch your service implementation layer. Simply find something like this:

    [ServiceContract(Namespace = "http://GlobalBank.CustomerProducts.ServiceContracts/2006/10", Name = "ICustomerFinder")]
    [ExceptionShielding("CustomerFinder")] // Enable exception shielding
    public interface ICustomerFinder
        [OperationContract(Action = "FindCustomer")]
        [FaultContract(typeof(SystemFault))]                // System unhandled fault
        CustomerFinderResponse FindCustomer(CustomerFinderRequest request);
Then you will add the required wiring metadata in the web.config file of the host project and your service implementation operations won't have any extra code or additional things.
Feb 1, 2008 at 2:25 PM
Charly (my) Friend ;-) Great, thats what I really was looking for. Thanks.