Skip to content

WCF – Logging Before and After Operation Invocation

Here’s another custom WCF EndpointBehavior I found useful recently.

Not content with logging all unhandled errors, I wanted to output a DEBUG level log message before and after every operation invocation. As before, I’m using the Castle Windsor Logging Facility to handle my logging, but you can swap that out for your logger of choice if required.

Firstly, here’s the EndPointBehaviour itself. This adds a custom CallContextInitializer to every service operation:

Here’s the custom CallContextInitializer:

And the Windsor configuration is much the same as last time:

Published inTech
Copyright © Ian Fraser Nelson 2023