WCF 操作日志记录
我想记录 WCF 操作的性能,特别是如果某个操作的执行时间超过给定阈值,则会在日志中创建警告。
我们首先实现 IDispatchMessageInspector,它允许我们对每个操作进行计时并执行日志记录。
但是,我希望能够将用户名附加到日志中,并且在调用 IDispatchMessageInspector 时似乎未设置 Thread.CurrentPrincipal。 (我们使用自定义用户名/密码并实施了 IAuthorizationPolicy)。
有没有办法从 IDispatchMessageInspector 获取用户名,或者有更好的选择来记录操作?
提前致谢 马特
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 WCF 跟踪
http://msdn.microsoft.com/en-us /library/ms733025.aspx
这包括带有开始和停止时间的活动跟踪。
You could use WCF Tracing
http://msdn.microsoft.com/en-us/library/ms733025.aspx
This includes activity tracing with start and stop times.