tags:

views:

136

answers:

1

Hi,

I'd like to log the performance of our WCF operations, in particular if an operation takes longer to execute than a given threshold it creates a warning in a log.

We have started by implementing IDispatchMessageInspector which allows us to time each operation and perform the logging.

However, I'd like to be able to append the username to the log and it appears that the Thread.CurrentPrincipal is not set when the IDispatchMessageInspector is called. (We are using custom username/password and have implemented IAuthorizationPolicy).

Is there a way I can obtain the username from IDispatchMessageInspector, or is there a better option for me to log operations?

Thanks in advance Matt

+1  A: 

You could use WCF Tracing

http://msdn.microsoft.com/en-us/library/ms733025.aspx

This includes activity tracing with start and stop times.

Shiraz Bhaiji