If you want to know how your users call your ASP.NET Web API you can hook into the process by implementing a custom Message Handler. This is done by creating a class that inherits from DelegatingHandler. In the overwritten SendAsync method you can implement your logging structure:
public class UrlCallLogger : DelegatingHandler { protected override Task<HttpResponseMessage> SendAsync( HttpRequestMessage request, CancellationToken cancellationToken) { Debug.WriteLine(request.RequestUri); // do more with your logging // [...] return base.SendAsync(request, cancellationToken); } }
Then in the Register method of the WebApiConfig class you have to add following line:
config.MessageHandlers.Add(new UrlCallLogger());
About how to config
Advertisements