Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS 7 Logging Web Service methods

I have a web service (not a WCF service) hosted under IIS 7, the web service has two methods: method1, and method2.

I am looking to differentiate between the requests for method1, versus the requests for method2, without modifying the web service code.

Under the IIS 7 logs, I can see the requests to the web service, the web service URL gets logged under the "cs-uri-stem" field, but the "cs-uri-query" field is empty.

Is there anyway to log the requests for the web service methods, without modifying the web service code?

like image 580
Life is more than this Avatar asked Jan 24 '12 18:01

Life is more than this


1 Answers

You can log all incoming request inside various methods of the processing pipeline. For example, add a handler for BeginRequest in your Global.asax:

Application_BeginRequest( object sender, EventArgs e )
{
    HttpApplication app = (HttpApplication)sender;
    HttpContext ctx = app.Context;

    var requestUrl = ctx.Request.Url;

    // the uri should be of a form:
    // http://yoursite/theservice.asmx/MethodName
}
like image 100
Wiktor Zychla Avatar answered Sep 22 '22 06:09

Wiktor Zychla