WCF logging and statistics [closed]
What is the best approach to log WCF services behaviour? For example, what operations were called, how lond did it take to complete one specific operation, input parameters and output result of the operation, operation name, who made the request (client IP address) and etc.开发者_StackOverflow
I found that article http://msdn.microsoft.com/en-us/magazine/cc163302.aspx Is it good directions to move forward?
Thanks
Check WCF Tracing (MSDN), it can be quite excessive in terms of data produced, but I think you´ll be able to retrieve the informatin you´re looking for. Alternativly, If you´re hosting the service yourself, check AppFabric for Windows Server (MSDN) for higher comfort diagnostics.
You may also want to checkout (enable) the WCF performance counters. The advantage over tracing (obviously) is, that it does have much less overhead and depending on the particular setting ("All" vs. "ServiceOnly" - see link for details) is also suitable for production.
Additionally, you might want to checkout the WMI support of WCF.
Finally - as you have already discovered - , you could extend WCF, e.g. implementing a "Message Inspector" and use that for logging/recording request duration (see here for a starting point - basically you "measure" request begin/end with using the AfterReceiveRequest
and BeforeSendReply
overrides).
Depending on your needs and actual implementation thereof, the last option has (a) the smallest footprint, (b) greatest flexibility but (c) requires you to write some code whereas the others are, well, "standardized" and work for any WCF service provide you can change its configuration.
精彩评论