We’re trying to create a simple to use webservice for logging exceptions and messages.
Ideally the web methods declaration would look like this
public int LogException(MethodBase methodBase, Exception exception)
public int LogMessage(MethodBase methodBase, string message, string data)
But that doesn’t work, since when you add a reference to a webservice it creates it’s own classes and System.Reflection.MethodBase is not the same type as LogService.MethodBase. And neither MethodBase or Exception serialize nicely. And I also want exception to have it’s Data values.
How would you go about passing those two objects to a webmethod?
The reason we were hoping to just pass those two objects is, between them, we can get 99% of the data needed to trace an error. They contain stack trace info, methodnames and the class they are in, etc, etc… And by adding some information to Exception.Data, you can have the parameters values at the time of the call. And, this simplifies the call for other devs, and hopefully makes them more likely to use a common logger, rather than always rolling their own. Which currently, is proving to be troublesome as each logger is different, and most don’t seem to include ALL the details necessary to track down an error.
By doing this, we can standardize the values returned, and email format, and make changes to all apps logging by changing one service.
Please don’t do this.
You should not use web services to pass platform-specific data. MethodBase etc are specific to .NET, and the web service infrastructure is not intended to accommodate it.
Why do you want a web service to do logging? Use a class library instead. You don’t want your logging to fail because of problems with a web service.
Finally, if you must do this, don’t use ASMX web services to do it – use WCF, which will allow you to use the same type on both the client and the service.
Perhaps more importantly, WCF will allow you to use MSMQ as a transport, so that you can use reliable queues to ensure that your log messages are eventually logged.
I still doubt that you really want to send the MethodBase – send the data that’s in the MethodBase, instead. What will you do about .NET version dependencies?