I have several web services that logged-in user interact with. Currently they're running on ASMX but pending an upgrade to WCF. I'm going to write a logger that tracks the name of the request, the user ID, the parameters, the time processing time, if there was an error and a few other things. I'm thinking of something like this:
public class MyWebService : System.Web.Services.Webservice
{
MyAppLogger TheAppLogger = new MyAppLogger();
[WebMethod(EnableSession = true)]
public string SomeWebService(string SomeParameters)
{
TheAppLogger.StartLogging();
TheJsonStringToReturn = "";
try
{
//do something that populates TheJsonStringToReturn
}
catch
{
TheAppLogger.LogException();
}
TheAppLogger.LogRequest();
return TheJsonStringToReturn;
}
}
My question is this: if I go with what I just described, the LogRequest()
method would store the request in the DB before the request is complete. Is that going to be performance problem? How would I change this code so that the database write would happen AFTER the request is responded to?
Thanks for your suggestions.